#P2781. 传教
传教
Description
pear lines up the people who are about to receive preaching in a row, numbered from left to right as . Each person has a faith value, and initially all faith values are . Then pear will perform one of the following two operations:
-
pear preaches to a continuous segment of people. Specifically, pear will increase the faith value of every person from the -th to the -th person by .
-
pear wants to know the sum of faith values over a segment to see whether the "Quanling spirit" has taken root. Specifically, pear will ask bx2k for the sum of the faith values of all people from the -th to the -th person.
As a believer in the "Quanling spirit," bx2k naturally wants to help pear calculate. However, bx2k is too clumsy to do the math, so he is asking you for help.
Input Format
The first line contains two integers , representing the number of people receiving preaching and the number of operations by pear, respectively.
The next lines each contain several integers. If the first integer is , it means pear is preaching, and this line will then contain three integers . Otherwise, if the first integer is , it means pear is making a query, and this line will then contain two integers .
Output Format
Output several lines, each containing integer, representing the answer to pear’s query. The number of lines equals the number of queries.
5 5
2 1 2
1 4 4 2
1 2 4 7
1 4 5 6
2 3 4
0
22
Hint
Sample explanation: Initially, everyone’s faith value is , so the answer is . By the time of the fifth operation, the five people’s faith values are . Thus, the answer is .
Constraints: | Test point | | Special property | |:-:|:-:|:-:| | | | None | | | | None | | | | Special property A |
Special property A: No preaching operations.
For all test points, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号