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);
}
}
}
;
}
最新文章
- 解决NetBeans编辑器中文乱码问题
- AOP常用术语
- mongodb,redis,hbase 三者都是nosql数据库,他们的最大区别和不同定位是什么?
- 【BZOJ】【1770】【Usaco2009 Nov】lights 灯
- mysql 只给更新表的某个字段的授权
- 打印NxN的矩阵
- C语言库函数大全及应用实例三
- ARC属性中还能使用assign,copy,retain这些关键字吗
- 纯CSS图片缩放后显示详细信息
- spring基本知识
- 面向对象编程思想(OOP)
- amazeUI的confirm控件记录缓存问题的解决办法
- 解决XP系统任务管理器显示不全
- Python+Selenium学习--下载文件
- C#基础知识回顾-- 属性与字段
- Android之AppWidget
- linux -- 管道“|”
- Qt的窗口的最大化。
- Java虚拟机6:垃圾收集(GC)-1(内存溢出和内存泄漏的区别)
- QMetaEnum利用Qt元数据实现枚举(enum)类型值及字符串转换