当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5238:Calculator

题目描述
Sakura has invented a new kind of calculator that can evaluate expressions. This calculator maintains a serial of operators and numbers inside. All these numbers and operators form an ordered table. For example

$*4 \quad + 2 \quad \hat{} 3 \quad + 8 \quad * 6$

is a possible table. The calculator also supports the following two operations.

1. 1 $x$.

This corresponds to the evaluation operation. For instance, if $x=2$, together with the table being the one described above, the calculator will output

$ ((((2*4)+2)^3)+8)*6=6048.$

As for $x=3$, it will output

$((((3*4)+2)^3)+8)*6=16512.$

2. 2 $p$ $cx$.

This corresponds to the modification operation. The calculator will change the $p$-th term in the expression to $cx$. Here $c$ denotes an operator while $x$ denotes a number.

For example, if $p=3$ and $cx=*5$, the expression will become

$*4 \quad + 2 \quad *5 \quad + 8 \quad * 6.$

Now you are asked to implement this calculator. However, for technical reasons, you should just output the result modulo 29393. It is guaranteed that, in all terms appeared in the input data, $c \in \{+, *, \hat{} \}$, $0 \le x < 29393$.
输入解释
The first line contains an integer $T$($T \le 10$), denoting the number of test cases. It is guaranteed that $1 \le n, m \le 50000$.

For each test case, the first line contains two numbers $n, m$. $n$ denotes the number of terms in the expression, $m$ denotes the number of operations.

In the following $n$ lines, each line contains a term in style of $cx$, denotes each term in the initial table.

In the following $m$ lines, each line contains an operation. It must in style of ''$1 \quad x$'' or ''$2\quad p \quad cx$''.
输出解释
For each test case, output Case #t: in a single line to represent the $t$-th case.
Then in each test case, output the result modulo 29393 for each evaluation operation.
输入样例
2
5 4
*4
+2
^3
+8
*6
1 2
1 3
2 3 *5
1 3
4 3
*4
^4
+4
*10
1 1
2 3 ^4
1 1
输出样例
Case #1:
6048
16512
468
Case #2:
2600
4107
P
来自杭电HDUOJ的附加信息
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5238

最后修改于 2020-10-25T23:20:57+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 131072/131072K(Java/Others)