#P2028. 龙兄摘苹果
龙兄摘苹果
Description
In the same orchard where Tao Tao picked apples, Long Xiong picked completely distinct apples. The hospitable owner provided him with baskets. He wants to put the apples into the baskets and carry them home (since Long Xiong’s hands are infinitely large, you do not need to consider whether he can carry multiple baskets at once).
He also does not want any basket to be empty, so as to make full use of the baskets. Therefore, he wants to know how many ways there are to distribute the apples. Because his brain computes slowly, he has asked you for help. He has already spent a long time picking apples, so he can only wait second.
Since the number of ways may be extremely large, he will give you a number ; output the remainder when the number of ways is divided by .
Two distributions are considered the same if each basket contains the same set of apples, and the order of baskets does not matter.
Input Format
One line with three integers , , and , as described above.
Output Format
A single integer: the remainder when the number of ways is divided by , followed by a newline.
4 2 3
1
Hint
Sample explanation:
There are apples and baskets.
There are the following ways.
- .
- .
- .
- .
- .
- .
- .
divided by leaves a remainder of .
Constraints:
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , .
It is guaranteed for all testdata that , and the answer fits in a -bit integer.
Translated by ChatGPT 5
京公网安备 11011102002149号