hdu 5238 Calculator(线段树,中国剩余定理¥)
Calculator
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 521 Accepted Submission(s): 170
∗4+2^3+8∗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+2∗5+8∗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∈{+,∗,^}, 0≤x<29393.
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 ''1x'' or ''2pcx''.
Then in each test case, output the result modulo 29393 for each evaluation operation.
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
6048
16512
468
Case #2:
2600
4107
P
hdu 5238 Calculator(线段树,中国剩余定理¥)的更多相关文章
- HDU 5238 Calculator 线段树 中国剩余定理
题意: 给一个计算器,有一系列计算步骤,只有加,乘,幂三种运算. 有一种查询操作:查询初始值为\(x\)的时候,最终运算结果模\(29393\)的值. 有一种修改操作:可以修改第\(p\)个运算的运算 ...
- hdu 4031 attack 线段树区间更新
Attack Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Subm ...
- hdu 4288 离线线段树+间隔求和
Coder Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- hdu 3016 dp+线段树
Man Down Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- HDU 5877 dfs+ 线段树(或+树状树组)
1.HDU 5877 Weak Pair 2.总结:有多种做法,这里写了dfs+线段树(或+树状树组),还可用主席树或平衡树,但还不会这两个 3.思路:利用dfs遍历子节点,同时对于每个子节点au, ...
- HDU 3308 LCIS (线段树区间合并)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 题目很好懂,就是单点更新,然后求区间的最长上升子序列. 线段树区间合并问题,注意合并的条件是a[ ...
- HDU 2795 Billboard (线段树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 题目大意:有一块h*w的矩形广告板,要往上面贴广告; 然后给n个1*wi的广告,要求把广告贴 ...
- hdu 5480 Conturbatio 线段树 单点更新,区间查询最小值
Conturbatio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=54 ...
- hdu 1828 Picture(线段树 || 普通hash标记)
http://acm.hdu.edu.cn/showproblem.php?pid=1828 Picture Time Limit: 6000/2000 MS (Java/Others) Mem ...
- hdu 4747【线段树-成段更新】.cpp
题意: 给出一个有n个数的数列,并定义mex(l, r)表示数列中第l个元素到第r个元素中第一个没有出现的最小非负整数. 求出这个数列中所有mex的值. 思路: 可以看出对于一个数列,mex(r, r ...
随机推荐
- MariaDB数据库主从复制实现步骤
一.MariaDB简介 MariaDB数据库的主从复制方案,是其自带的功能,并且主从复制并不是复制磁盘上的数据库文件,而是通过binlog日志复制到需要同步的从服务器上. MariaDB数据库支持单向 ...
- mysql数据库中表记录的玩法
一.增加表记录(相当于插入表记录) 1. 插入完整数据(顺序插入) 语法一: INSERT INTO 表名(字段1,字段2,字段3…字段n) VALUES(值1,值2,值3…值n); 语法二: INS ...
- NodeJS 加入windows7服务 开机运行 nssm
from:http://blog.sina.com.cn/s/blog_5ef5f2630101aql8.html 首先需要到http://nssm.cc/download/?page=downloa ...
- PAT 天梯赛 L1-006. 连续因子 【循环】
题目链接 https://www.patest.cn/contests/gplt/L1-006 思路 输出的连续因子 的乘积 也要是这个数的因子 就每个数先找它的单因子 然后每个单因子往上一个一个遍历 ...
- iOS git 托管代码 常用几个操作
学习 git 切换分支 1 从远程下载一个分支develop(本地没有的) (1) git fetch origin develop (2) git checkout develop (默认 分支切 ...
- 安装好MySQL后就开始学习如何后台创建自己的数据库吧!
MySQL创建数据库的方式不像SQL Server那样有图形界面,而是使用DOS窗口创建的,接下来就是创建MySQL数据库的具体步骤. ↓↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓ ↓↓↓↓ ...
- Linux sh远程连接失败 sshd.service启动失败
今天不小心在本机的虚拟机执行了 chmod -R 777 /var 导致/var目录下所有权限全部是777 其中 /var/empty/sshd目录权限必须是744,却被改成了777,致使sh远程连接 ...
- 【leetcode刷提笔记】Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the ...
- get_called_class--后期静态绑定("Late Static Binding")类的名称
get_called_class--后期静态绑定("Late Static Binding")类的名称 string get_called_class ( void ) 获取静态方 ...
- Java中系统时间的获取_currentTimeMillis()函数应用解读
快速解读 System.currentTimeMillis()+time*1000) 的含义 一.时间的单位转换 1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)1秒=1,000,000 微 ...