spoj#DCEPC11I. Impossible Boss
Impossible Boss
本题没有可用的提交语言。
Vaibhav Sir and Saikat Sir, after completing their graduation, got a job together at a store.
Their boss at the store was Sidharth Sir, who was very strict and did not want anyone to have fun at the job. He gave Vaibhav and Saikat sir a very boring job of stacking columns of boxes in a row of size N.
To make it a little interesting, both of them decided that whenever they need to add more boxes, they will choose st and en, such that 1<=st<=en<=N, and place 1 box in column st, 2 boxes in column st+1, … and (en-st+1) boxes in column en.
When Sidharth sir saw this, he decided to have some fun of his own, and asked them to count the number of boxes in all columns from st to en, and tell him the result. Now Vaibhav and Saikat sir have come to you for help to answer the queries of their boss, as they do not want to lose their jobs.
Input
The first line contains N, the number of columns and Q, the number of queries.
The next Q lines can be of the following form –
1) 0 st en, meaning Vaibhav and Saikat sir add boxes to the columns from st to en as described above.
2) 1 st en, meaning Sidharth sir asks them to count the number of boxes in all columns from st to en.
Output
For all queries of type 2, output a line containing the answer to the query.
Example
Input: 5 6</p>
0 2 4
1 1 5
0 1 5
0 3 5
1 1 5
1 3 5Output: 6
27
23
Constraints:
1<=N, Q<=100000