atcoder#ARC160D. [ARC160D] Mahjong
[ARC160D] Mahjong
Score : points
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 .
- 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.
3 2 2
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 .
100 998244353 100
0
There may be no sequence that satisfies the requirements.
2000 545782618661124208 533
908877889