Responsive image

问题 C: Rikka with Sequence

问题 C: Rikka with Sequence

时间限制: 15 Sec  内存限制: 128 MB
提交: 2  解决: 1
[提交][状态][讨论版][命题人:]

题目描述

As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:

Yuta has an array A with n numbers and he keeps a copy of the initial value of array A as A′(A′i=Ai). Then he makes m operations on it. 

There are three types of operations:
1 l r: Yuta wants Rikka to sum up Ai for all i in [l,r].
2 l r k: Yuta runs the C++ code “for (int i=l;i<=r;i++) A[i]=A[i-k]” on sequence A. (The pascal version of the code snippet is “for i:=l to r do A[i]:=A[i-k]”). 
3 l r: Yuta changes Ai back to A′i, for all i∈[l,r].

It is too difficult for Rikka. Can you help her?

输入描述

The first line contains two numbers 1≤n,m≤2×105. 
The second line contains n numbers Ai. Then m lines follow, each line describe an operation. 
It is guaranteed that 1≤k<l,0≤Ai≤109

输出描述

For each query, print a single line with a single number -- the answer.

样例输入

5 7
1 2 3 4 5
1 1 5
2 3 4 1
1 1 5
2 3 4 2
1 1 5
3 1 5
1 1 5

样例输出

15
12
11
15
[提交][状态]
ACM算法攻关部