请教一道算法题# JobHunting - 待字闺中
x*0
1 楼
A spreadsheet consists of a two-dimensional array of cells, labeled A1, A2,
etc. Rows are identified using letters, columns by numbers. Each cell
contains either an integer (its value) or an expression. Expressions contain
integers, cell references, and other operators '+', '-', '*', '/' with the
usual rules of evaluation -- note that the input is RPN and should be
evaluated in stack order.
The spreadsheet input is defined as follows:
(a) Line 1: two integers, defining the width and height of the spreadsheet (
n, m)
(b) n*m lines each containing an expression which is the value of the
corresponding cell (cells enumerated in the order A1, A2, A, B1, ...)
For example:
Input
3 2
A2
4 5 *
A1
A1 B2 / 2 +
3
39 B1 B2 * /
Output
3 2
20.0
20.0
20.0
8.7
3.0
1.5
The above example input visually looks like:
|1 |2 |3 |
--------------------------------------------------
A |A2 |4 5 * |A1 |
--------------------------------------------------
B |A1 B2 / 2 + |3 |39 B1 B2 * / |
--------------------------------------------------
etc. Rows are identified using letters, columns by numbers. Each cell
contains either an integer (its value) or an expression. Expressions contain
integers, cell references, and other operators '+', '-', '*', '/' with the
usual rules of evaluation -- note that the input is RPN and should be
evaluated in stack order.
The spreadsheet input is defined as follows:
(a) Line 1: two integers, defining the width and height of the spreadsheet (
n, m)
(b) n*m lines each containing an expression which is the value of the
corresponding cell (cells enumerated in the order A1, A2, A
For example:
Input
3 2
A2
4 5 *
A1
A1 B2 / 2 +
3
39 B1 B2 * /
Output
3 2
20.0
20.0
20.0
8.7
3.0
1.5
The above example input visually looks like:
|1 |2 |3 |
--------------------------------------------------
A |A2 |4 5 * |A1 |
--------------------------------------------------
B |A1 B2 / 2 + |3 |39 B1 B2 * / |
--------------------------------------------------