F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Calculator

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1220    Accepted Submission(s): 426


Problem Description
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$.
 

Input
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$''.
 

Output
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.
 

Sample Input
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
 

Sample Output
Case #1: 6048 16512 468 Case #2: 2600 4107 P
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 19:26:50, Gzip enabled