438D - The Child and Sequence
4 seconds
256 megabytes
standard input
standard output
At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks.
Fortunately, Picks remembers how to repair the sequence. Initially he should create an integer array a[1], a[2], ..., a[n]. Then he should perform a sequence of m operations. An operation can be one of the following:
- Print operation l, r. Picks should write down the value of
.
- Modulo operation l, r, x. Picks should perform assignment a[i] = a[i] mod x for each i (l ≤ i ≤ r).
- Set operation k, x. Picks should set the value of a[k] to x (in other words perform an assignment a[k] = x).
Can you help Picks to perform the whole sequence of operations?
The first line of input contains two integer: n, m (1 ≤ n, m ≤ 105). The second line contains n integers, separated by space:a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109) — initial value of array elements.
Each of the next m lines begins with a number type .
- If type = 1, there will be two integers more in the line: l, r (1 ≤ l ≤ r ≤ n), which correspond the operation 1.
- If type = 2, there will be three integers more in the line: l, r, x (1 ≤ l ≤ r ≤ n; 1 ≤ x ≤ 109), which correspond the operation 2.
- If type = 3, there will be two integers more in the line: k, x (1 ≤ k ≤ n; 1 ≤ x ≤ 109), which correspond the operation 3.
For each operation 1, please print a line containing the answer. Notice that the answer may exceed the 32-bit integer.
这题关键是证明啊。 好线段树。
详细证明见:http://codeforces.com/blog/entry/12513


;
typedef ],Max[MAX<<];
]+sum[o<<|];
Max[o]=max(Max[o<<],Max[o<<|]);
}
;
build(L,mid,o<<);
build(mid+,R,o<<|);
push_up(o);
}
;
,ls,rs,mod);
,R,o<<|,ls,rs,mod);
push_up(o);
}
;
,k,x);
,R,o<<|,k,x);
push_up(o);
}
LL Query(;
;
,ls,rs);
,R,o<<|,ls,rs);
) {
build(,n,);
;i<m;i++) {
scanf() {
scanf(,n,,l,r));
}
) {
scanf(,n,,l,r,x) ;
}
,n,,k,x);
}
}
}
;
}
438D - The Child and Sequence的更多相关文章
- 题解——CodeForces 438D The Child and Sequence
题面 D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input ...
- Codeforces 438D The Child and Sequence - 线段树
At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at ...
- Codeforces 438D The Child and Sequence
题意:给定一个n个数的序列,完成以下3个操作: 1.给定区间求和 2.给定区间对x取模 3.单点修改 对一个数取模,这个数至少折半.于是我们记一个最大值max,如果x>max则不做处理. #in ...
- 2018.07.23 codeforces 438D. The Child and Sequence(线段树)
传送门 线段树维护区间取模,单点修改,区间求和. 这题老套路了,对一个数来说,每次取模至少让它减少一半,这样每次单点修改对时间复杂度的贡献就是一个log" role="presen ...
- CF(438D) The Child and Sequence(线段树)
题意:对数列有三种操作: Print operation l, r. Picks should write down the value of . Modulo operation l, r, x. ...
- CodeForces 438D The Child and Sequence (线段树 暴力)
传送门 题目大意: 给你一个序列,要求在序列上维护三个操作: 1)区间求和 2)区间取模 3)单点修改 这里的操作二很讨厌,取模必须模到叶子节点上,否则跑出来肯定是错的.没有操作二就是线段树水题了. ...
- Codeforce 438D-The Child and Sequence 分类: Brush Mode 2014-10-06 20:20 102人阅读 评论(0) 收藏
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...
- Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间取摸
D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- Codeforces Round #250 (Div. 1) D. The Child and Sequence(线段树)
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...
随机推荐
- P4161 [SCOI2009]游戏
传送门 首先这题的本质就是把\(n\)分成若干个数的和,求他们的\(lcm\)有多少种情况 然后据说有这么个结论:若\(p_1^{c_1}+p_2^{c_2}+...+p_m^{c_m}\leq n\ ...
- JavaScript编程艺术-第10章-10.2-实用的动画
10.2-实用的动画 ***代码亲测可用*** HTML: <!DOCTYPE HTML> <html> <head> <meta charset=" ...
- C - GCD LCM
Description The GCD of two positive integers is the largest integer that divides both the integers w ...
- ACM_Scramble Sort
Scramble Sort Time Limit: 2000/1000ms (Java/Others) Problem Description: In this problem you will be ...
- ActiveMQ命令行工具
命令行工具 命令行工具 n activemq——运行activemq代理 n activemq-admin——管理代理的实例 在5.0之前activemq-admin被分成多个脚本,例如 ...
- 274 H-Index H指数
给定一位研究者的论文被引用次数的数组(被引用次数是非负整数).写一个方法计算出研究者的H指数.H-index定义: “一位科学家有指数 h 是指他(她)的 N 篇论文中至多有 h 篇论文,分别被引用了 ...
- 网站开发综合技术 HTML
HTML 内容(Hyper Text Markup Language,超文本标记语言) CSS 网页美化 Javascript 脚本语言 第一部 ...
- C语言学习(1)-环境配置
写在前面的话,该文章是看杨老师的一套视频,所做的一些笔记,边看边写,再此谢谢杨老师. 1.学习C之前需要避免的误区 误区一:C++是C的升级版:C#是C++的升级版 误区二:C/C++就是Visual ...
- iOS检测耳机插入拔出
首先,需要导入两个框架 然后,注册通知检测耳机的插入与拔出操作 [[NSNotificationCenter defaultCenter] addObserver:self selector:@sel ...
- grunt 全局使用
grunt 不同地方使用时需要将插件下载的当前文件夹,这是因为查找模块时是当前路径,这会造成多个工程使用时会需要下载多次,而这些东西又不应该存在于工程之中,所以应该将所有模块全局安装,然后在工程下面只 ...