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 ...
随机推荐
- es6数组的一些函数方法使用
数组函数forEach().map().filter().find().every().some().reduce()等 数组函数(这里的回调函数中的index和arr都可以省略,回调函数后有参数是设 ...
- 扩展运算符和rest运算符
扩展运算符 扩展运算符用三个点号表示,功能是把数组或类数组对象展开成一系列用逗号隔开的值 一.拆分数组 扩展运算符可以直接把数组拆分成用逗号隔开的值 <template> <sect ...
- python模块学习(四)
re模块 就其本质而言,正则表达式(或 RE)是一种小型的.高度专业化的编程语言,(在Python中)它内嵌在Python中,并通过 re 模块实现.正则表达式模式被编译成一系列的字节码,然后由用 C ...
- 斯坦福大学Andrew Ng - 机器学习笔记(7) -- 异常检测
大概用了一个月,Andrew Ng老师的机器学习视频断断续续看完了,以下是个人学习笔记,入门级别,权当总结.笔记难免有遗漏和误解,欢迎讨论. 鸣谢:中国海洋大学黄海广博士提供课程视频和个人笔记,在此深 ...
- postgrSQL 错误ERROR: permission denied
赋权限: GRANT ALL PRIVILEGES ON TABLE 表名 TO 用户;
- Ubantu安装Odoo10学习日志
Windows安装是十分简单的,无论是何种方式,在了解大体情况下,我开始尝试下将Odoo搭建部署在Ubantu上. 1.Odoo是什么? Odoo是一个开源框架,针对ERP的需求发展出来,适合定制出符 ...
- Activiti 5.16 流程图高亮追踪 中文乱码问题解决方法
最近研究activiti的高亮流程图,发现中文是乱码,为了让大家少走弯路共享出来. 本文包含三个主要技术点: 1.spring MVC架构下输出动态图片 2.获得activiti流程图的stream流 ...
- java上机
package wordcont; import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayLi ...
- C#如何使用结构化异常处理
Knowledge Base: Chinese (Simplified) 如何使用 Visual C# .NET 和 Visual C# 2005 中的结构化异常处理文章ID: 816157 最近更新 ...
- LeetCode:路径总和【112】
LeetCode:路径总和[112] 题目描述 给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和. 说明: 叶子节点是指没有子节点的节点. 示例 ...