#P10374. [AHOI2024 初中组 / 科大国创杯初中组 2024] 操作
[AHOI2024 初中组 / 科大国创杯初中组 2024] 操作
Background
The testdata for this problem is not official.
Official testdata (that can be uploaded here) is being collected.
Official testdata (that cannot be uploaded here): https://www.luogu.com.cn/training/499869
Unofficial testdata download: https://scg3.piaoztsdy.cn/training/69bce235a7cf509104565c83
Problem Description
Xiaokeke has an array (initially ) and machines arranged from left to right. For the -th machine, its type is and its parameters are . The operation performed by the -th machine is as follows:
- If , add to . It is guaranteed that and .
- If , perform the operations of machines once each. It is guaranteed that .
- In particular, it is guaranteed that .
Now Xiaokeke executes the operations of machines once each in order. She wants to know what the final array is.
Since the values in the array may be very large, you only need to output the remainder of each element modulo .
Input Format
The first line contains three positive integers .
The next line contains positive integers .
The next lines each contain three positive integers on the -th line.
Output Format
Output one line with non-negative integers, representing the remainder of each element in modulo .
2 3 3
1 2 3
1 1 2
2 1 1
2 1 2
8 0
Hint
Sample 1 Explanation
First, execute the operation of machine , which adds to .
Then execute the operation of machine . It operates machine , adding to .
Then execute the operation of machine . It first operates machine , adding to ; then it operates machine , and machine operates machine again, adding to .
In summary, the final array is .
Constraints
For of the testdata, .
For of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , , , and . In addition, for the -th machine, it is guaranteed that:
- If , then and .
- If , then .
Translated by ChatGPT 5