Logo
(追記) (追記ここまで)

7866번 - Spreadsheet 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB5000.000%

문제

You are to write a program emulating a very simple spreadsheet application. It works with a table with 9 rows, from 1 to 9, and 26 columns, from A to Z. Table cells are referenced by names composed of column and row codes, ex. B1, S8.

Each cell contains an expression up to 255 characters long. Expressions use integer constants, cell references, parenthesis, operators +, -, *, and / (whole division). For example: 567, E8/2, (3+B3)*(C4-1) are all valid expressions. All operators are whole, all arguments and results are guaranteed to be less than 1000000. Division by zero yields zero.

If the value of the cell referenced by some expression is not defined, it is presumed to be 0 (zero). The situation when two or more cells are mutually dependent on each other is considered a special case of circular reference.

입력

First input line contains number of expressions N. Following N lines are in format <Cell reference>=<expression>. All expressions are correct, and each cell is defined by at most one expression.

출력

Output file must contain single line with either the value of the cell A1 or number 1000000 (one million) if the value of A1 cannot be computed due to a circular reference.

제한

예제 입력 1

4
A1=B1+C5
B1=20
C5 =B1 /D7-E1*E1
E1=(3+1)*2

예제 출력 1

-44

힌트

출처

ICPC > Regionals > Northern Eurasia > Far Eastern Russia Regional Contest > NEERC Far-Eastern Subregional 2000 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /