atcoder#ABC231G. [ABC231G] Balls in Boxes
[ABC231G] Balls in Boxes
Score : points
Problem Statement
We have boxes numbered to . Initially, Box contains balls.
You will repeat the following operation times.
- Choose one box out of the uniformly at random (each time independently). Add one ball to the chosen box.
Let be the number of balls in Box after the operations, and the score be the product of the numbers of balls, .
Find the expected value of the score modulo .
Notes
When the expected value in question is represented as an irreducible fraction , there uniquely exists an integer such that and under the Constraints of this problem. This is the value we seek.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 1
1 2 3
665496245
After the operation, the score will be as follows.
- When choosing Box in the operation, .
- When choosing Box in the operation, .
- When choosing Box in the operation, .
Therefore, the expected value in question is . This value modulo is .
2 2
1 2
499122182
After the operations, the score will be as follows.
- When choosing Box in the first operation and Box in the second, .
- When choosing Box in the first operation and Box in the second, .
- When choosing Box in the first operation and Box in the second, .
- When choosing Box in the first operation and Box in the second, .
Therefore, the expected value in question is .
10 1000000000
998244350 998244351 998244352 998244353 998244354 998244355 998244356 998244357 998244358 998244359
138512322