#P13280. 「CZOI-R4」午夜巡游
「CZOI-R4」午夜巡游
Description
There is a permutation of length (each integer from to appears exactly once in ) and a variable , initially set to .
You need to perform operations, where each operation updates to .
Find the sum of all possible values of after operations, considering all possible permutations , modulo .
Input Format
This problem contains multiple test cases.
The first line contains an integer .
Each of the next lines contains three integers , , .
Output Format
Output lines, each containing one integer representing the answer for the corresponding test case.
6
3 5 3
114514 0 100000
501 1 249
9982443 231406890 1
9876543 735134400 421704
10000000 180957102 998140
12
616064221
532050777
653339286
829601668
778347084
Hint
Sample Explanation
For the first test case:
- All possible permutations and their corresponding sequences:
- :
- :
- :
- :
- :
- :
- Final answer: .
Constraints
This problem uses bundled testing.
| Subtask | Score | Constraints |
|---|---|---|
| #1 | 15 pts | , |
| #2 | 20 pts | |
| #3 | ||
| #4 | ||
| #5 | 25 pts | No additional constraints |
For all cases: , , .
京公网安备 11011102002149号