#P10380. 「ALFR Round 1」D 小山的元力
「ALFR Round 1」D 小山的元力
Problem Description
Xiaoshan has identical elements. He wants to divide these elements into piles. Obviously, there are many ways to do this. For each division, let be the number of elements in the -th pile, (where denotes the factorial of ), and . Xiaoshan's elemental power is defined as the sum of the values of over all divisions. Xiaoshan wants to know what his elemental power is. Since the answer may be very large, output the final answer modulo (it is guaranteed that is a prime number).
Input Format
One line with three integers , with meanings given in the Description.
Output Format
Output one number representing Xiaoshan's elemental power.
3 2 37
18
Hint
Sample Explanation
The ways to divide elements into piles are:
0 31 22 13 0
Xiaoshan's elemental power is: $(1!\times0+2!\times3)+(1!\times1+2!\times2)+(1!\times2+2!\times1)+(1!\times3+2!\times0)=18$.
Constraints
| Subtask | Score | Constraints |
|---|---|---|
| - |
For of the testdata, , .
Translated by ChatGPT 5