Problem Description
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.
Input
<p>The first line contains two numbers <i>N</i> and <i>Q</i>. 1 ≤ <i>N</i>,<i>Q</i> ≤ 100000.<br>The second line contains <i>N</i> numbers, the initial values of <i>A</i><sub>1</sub>, <i>A</i><sub>2</sub>, ... , <i>A<sub>N</sub></i>. -1000000000 ≤ <i>A<sub>i</sub></i> ≤ 1000000000.<br>Each of the next <i>Q</i> lines represents an operation.<br>"C <i>a</i> <i>b</i> <i>c</i>" means adding <i>c</i> to each of <i>A<sub>a</sub></i>, <i>A<sub>a</sub></i><sub>+1</sub>, ... , <i>A<sub>b</sub></i>. -10000 ≤ <i>c</i> ≤ 10000.<br>"Q <i>a</i> <i>b</i>" means querying the sum of <i>A<sub>a</sub></i>, <i>A<sub>a</sub></i><sub>+1</sub>, ... , <i>A<sub>b</sub></i>.</p>
Output
<p>You need to answer all <i>Q</i> commands in order. One answer in a line.</p>
Sample Input
Sample Output
题目大概和思路:
区间更新,区间求和。基础操作之一。
不过我写的代码变量不好分辨,错了好多次。
具体做法,前面日记中提到过。
直接代码
: