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 ...
 
随机推荐
- SpringBoot + Thymeleaf + Validate验证
			
在开发业务时,不可避免的需要处理一些校验, 如果是写 if-else 这种代码去校验, 那会有一大段这样的代码.不过还好有个校验插件: javax.validation.validation-api ...
 - [NOIP2018TG]赛道修建
			
[NOIP2018TG]赛道修建 考场上multiset调不出啊啊啊!!! 首先肯定是二分答案 做树形dp,f[i]表示i点的子树两两匹配后剩下的最长长度 匹配可以用multiset维护 但是菊花图跑 ...
 - ThinkPHP在入口文件中判断是手机还是PC端访问网站
			
<?php// +----------------------------------------------------------------------// | ThinkPHP [ WE ...
 - python并发编程&多线程(一)
			
本篇理论居多,实际操作见: python并发编程&多线程(二) 一 什么是线程 在传统操作系统中,每个进程有一个地址空间,而且默认就有一个控制线程 线程顾名思义,就是一条流水线工作的过程,一 ...
 - Python 网络编程——socket
			
一 客户端/服务器架构 客户端(Client)服务器(Server)架构,即C/S架构,包括 1.硬件C/S架构(打印机) 2.软件C/S架构(web服务) 理想/目标状态—— 最常用的软件服务器是 ...
 - python下多线程的限制以及多进程中传递参数的方式
			
python多线程有个全局解释器锁(global interpreter lock),这个锁的意思是任一时间只能有一个线程使用解释器,跟单cpu跑多个程序一个意思,大家都是轮着用的,这叫“并发”,不是 ...
 - PyNN:神经网络模拟器的通用接口
			
PyNN:神经网络模拟器的通用接口 计算神经科学已经产生了用于模拟神经元网络的多样化软件,同时具有消极和积极的后果.一方面,每个模拟器都使用自己的编程或配置语言,导致将模型从一个模拟器移植到另一个模拟 ...
 - mysql-5.7.16-linux-glibc2.5-x86_64精简后的主从配置
			
1.创建复制账号,并授予复制权限CREATE USER 'fansik'@'10.%' IDENTIFIED BY 'fansik';GRANT REPLICATION SLAVE ON *.* TO ...
 - $SublimeText2常用快捷键
			
1.删除一行:ctrl + shift + K2.替换:ctrl + H3.设置书签:Ctrl+F2设置书签F2 下一个书签Shift+F2上一个书签4.查找:ctrl + F 查找F3 查找下一个s ...
 - 013_HDFS文件合并上传putmarge功能(类似于hadoop fs -getmerge)
			
场景 合并小文件,存放到HDFS上.例如,当需要分析来自许多服务器的Apache日志时,各个日志文件可能比较小,然而Hadoop更合适处理大文件,效率会更高,此时就需要合并分散的文件.如果先将所有文件 ...