#arc160d. [arc160_d]Mahjong
[arc160_d]Mahjong
Problem Statement
Find the number, modulo , of sequences of non-negative integers totaling that satisfy the following condition.
- It is possible to make all elements of equal by repeatedly choosing one of the following operations and performing it.
- Choose an integer such that and decrease by .
- Choose an integer such that and decrease each of by .
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 2 2
Sample Output 1
5
The following five sequences satisfy the requirements.
For instance, if , you can do the following to make all elements of equal .
- Perform the second operation. Choose to decrease each of and by , making .
Sample Input 2
100 998244353 100
Sample Output 2
0
There may be no sequence that satisfies the requirements.
Sample Input 3
2000 545782618661124208 533
Sample Output 3
908877889