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 ...
随机推荐
- [NOIP2018PJ]对称二叉树
[NOIP2018PJ]对称二叉树 这个题正常人看到题面难道不是哈希? 乱写了个树哈希... #include<bits/stdc++.h> using namespace std; co ...
- 什么是lambda函数?它有什么好处?
lambda 函数是一个可以接收任意多个参数(包括可选参数)并且返回单个表达式值的函数. lambda 函数不能包含命令,它们所包含的表达式不能超过一个.不要试图向lambda 函数中塞入太多的东西: ...
- Android系统移植与调试之------->如何修改开机动画的两种方式剖析
首先,我们先来分析一下源码: frameworks/base/cmds/bootanimation/BootAnimation.cpp 首先看一下定义的常量: BootAnimation::ready ...
- 关于handler内存泄露的问题
在使用Handler更新UI的时候.我是这样写的: public class SampleActivity extends Activity { private final Handler mLeak ...
- mysql大致学习路径
- Sql Server 2005 .bak备份文进行还原数据库
https://jingyan.baidu.com/article/9158e000250b91a25412283f.html https://www.cnblogs.com/webmen/p/575 ...
- linux虚拟机能ping通windows主机,windows主机ping不通linux虚拟机的解决办法
分三步: 1.虚拟机网络连接方式选择Nat
- solr-6.4.2安装+分词器配置
一.solr安装 solr下载地址:http://archive.apache.org/dist/lucene/solr/6.4.2/ 1.解压solr软件包:tar xf solr-6.4.2.tg ...
- Python爬虫:爬取自己博客的主页的标题,链接,和发布时间
代码 # -*- coding: utf-8 -*- """ ------------------------------------------------- File ...
- phoneGap实现离线缓存
引自:http://www.iteye.com/topic/1128173 正在做一个跨平台的应用,需要使用phonegap进行文件的一些基本操作. 需求如下:可以选择本地图片,或者从相机选择图片,并 ...