Rikka with Sequence

TimeLimit:5500MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
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.
SampleInput
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
SampleOutput
15
12
11
15
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数1
总提交量1
AC率100.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: