#P10005. [集训队互测 2023] 基础寄术练习题
[集训队互测 2023] 基础寄术练习题
Problem Description
For a sequence of length , define , where is the prefix sum array of , and is a given constant with .
Consider all sequences that satisfy the following three conditions:
- The length of is .
- , .
- .
Find the sum of over all such sequences. Output the answer modulo . It is guaranteed that is a prime.
Input Format
The first line contains four integers , representing the sequence length, the upper bound of the sequence elements, and the modulus.
Output Format
Output one integer: the answer modulo .
2 3 2 1000000007
966666675
3 5 2 998244353
148276980
6 10 2 1004535809
622165218
15 20 2 1064822107
53789887
30 40 1 265371653
179937201
Hint
For all testdata, it is guaranteed that , , and is a prime, and .
- Subtask 1 (10 pts): .
- Subtask 2 (25 pts): .
- Subtask 3 (15 pts): .
- Subtask 4 (10 pts): .
- Subtask 5 (15 pts): .
- Subtask 6 (10 pts): .
- Subtask 7 (15 pts): .
Translated by ChatGPT 5