10294: CF EDU - Segment Tree P2 - Step 4 - B. Add Arithmetic Progression On Segment
[Creator : ]
Description
You are given an array $x$, consisting of $n$ elements equal to $0$, and $m$ queries of two types:
- add an arithmetic progression to a segment: the query is described with four integers $l,r,a,d$ — for each $l≤i≤r$ you should perform $x_i+=a+d⋅(i−l)$;
- print current value of a given element.
Input
The first line contains two integers $n,m\ (1≤n,m≤2⋅10^5)$.
The next $m$ lines describe queries. Each line starts with integer $t\ (1≤t≤2)$ — type of the operation. For operations of the first type, four integers follow: $l,r,a,d\ (1≤l≤r≤n,\ 1≤a,d≤2⋅10^5)$. For operations of the second time one integer between $1$ and $n$ follows.
Output
For each query of the second type, print the answer.
Sample 1 Input
9 10
1 4 8 1 2
2 6
2 8
1 1 9 3 1
2 6
2 8
1 2 5 2 3
2 1
2 2
2 3
Sample 1 Output
5
9
13
19
3
6
10