atcoder#ARC134C. [ARC134C] The Majority
[ARC134C] The Majority
Score : points
Problem Statement
There are boxes numbered to . Initially, all boxes are empty.
Snuke has some balls with integers from to written on them. Among them, balls have the number . Balls with the same integer written on them cannot be distinguished.
Snuke has decided to put all of his balls in the boxes. He wants the balls with the number to have a majority in every box. In other words, in every box, the number of balls with should be greater than that of the other balls.
Find the number of such ways to put the balls in the boxes, modulo .
Two ways are distinguished when there is a pair of integers satisfying such that the numbers of balls with in Box are different.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of ways, modulo , to put the balls in the boxes so that the balls with the number have a majority in every box.
2 2
3 1
2
- There are two ways to put the balls so that the balls with the number will be in the majority.
- One way to do so is to put two of the balls with in Box and the other one in Box , and put the one ball with in Box .
2 1
1 100
0
- There may be no way to put the balls in the boxes to meet the requirement.
20 100
1073813 90585 41323 52293 62633 28788 1925 56222 54989 2772 36456 64841 26551 92115 63191 3603 82120 94450 71667 9325
313918676
- Be sure to find the count modulo .