|
||||||||||
Rikka with SequenceTime Limit: 11000/5500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 893 Accepted Submission(s): 197 Problem Description 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=A_i)$. Then he makes $m$ operations on it. There are three types of operations: $1\ l \ r$: Yuta wants Rikka to sum up $A_i$ 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 $A_i$ back to $A'_i$, for all $i \in [l,r]$. It is too difficult for Rikka. Can you help her? Input The first line contains two numbers $1 \leq n,m \leq 2 \times 10^5$. The second line contains n numbers $A_i$. Then m lines follow, each line describe an operation. It is guaranteed that $1 \leq k<l, 0 \leq A_i \leq 10^9$ Output For each query, print a single line with a single number -- the answer. Sample Input
Sample Output
Source | ||||||||||
|