#P3373. 【模板】线段树 2
【模板】线段树 2
Description
As stated, given a sequence , you need to perform the following three operations:
- Multiply every number in a given interval by .
- Add to every number in a given interval.
- Find the sum of every number in a given interval.
Input Format
The first line contains three integers , representing the number of elements in the sequence, the total number of operations, and the modulus.
The second line contains space-separated integers, where the -th number is the initial value of the -th element.
Each of the next lines contains several integers describing an operation, as follows:
Operation 1: Format: 1 x y k Meaning: multiply every number in the interval by .
Operation 2: Format: 2 x y k Meaning: add to every number in the interval .
Operation 3: Format: 3 x y Meaning: output the sum of every number in the interval modulo .
Output Format
Output several lines of integers, which are the results of all operation 3.
5 5 38
1 5 4 2 3
2 1 4 1
3 2 5
1 2 4 2
2 3 5 5
3 1 4
17
2
Hint
Constraints:
For of the testdata: , . For of the testdata: , . For of the testdata: , , .
Except for the samples, .
(The testdata has been strengthened ^_^.)
Sample explanation:

Therefore, the outputs should be and ().
Translated by ChatGPT 5
京公网安备 11011102002149号