시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 8 | 3 | 3 | 37.500% |
Expression evaluation is a classic problem. In this problem, you only need to evaluate an expression of length less than $10^5$. It may only contain non-negative integers (possibly with leading zeros), and also operations '+
', '-
', and '*
'. Formally, it satisfies the following grammar:
<expression>:= <term>|<expression>+<term>|<expression>-<term> <term>:= <number>|<term>*<number> <number>:= <digit>|<number><digit> <digit>:= 0|1|2|3|4|5|6|7|8|9
For example, 013
, 0213-2132*0213
are valid, but -2132
and 32113+-3213
are invalid.
The result of the evaluation may be too large or negative. Output the result modulo $2^{32}$ to avoid overflow since you will use a custom $32$-bit machine to evaluate the expression.
The $32$-bit machine contains $2^{10}$ units of memory, denoted as $r[0], r[1], \ldots, r[2^{10}-1]$. Each unit is a $32$-bit unsigned integer, also working as an instruction. The machine's input is an expression described above, and the machine's output is the value of that expression modulo $2^{32}$.
In each cycle, let $pc=r[0]\bmod 2^{10}$. The machine executes the instruction $r[pc]$. Consider the expansion $r[pc]=a2^{30}+b2^{20}+c2^{10}+d$ at the beginning of cycle, where $a$, $b$, $c$, $d$ are non-negative integers less than $2^{10}$:
Note that if $b=0$ in some instructions, $r[0]$ may be set more than once. Its value is the value set last after the cycle.
You need to set the initial value for each unit of memory so that, for any expression possible within the constraints, the machine can stop after a finite amount of cycles and output the result of the expression modulo $2^{32}$.
Since there is a time limit for testing, in this problem, the machine can execute at most $10^8$ cycles.
The only line contains a $32$-bit unsigned integer: the seed for the expression generator.
You do not need to use it. It is just for the checker to generate the expressions.
Output $2^{10}$ $32$-bit unsigned integers in the only line: the initial values of the memory units.
0
0 0 ... 0 (1024 zeros)
The output in the example is wrong. It is given just to explain the output format.