#abc231g. G - Balls in Boxes
G - Balls in Boxes
Score : points
问题描述
我们有 个编号为 到 的盒子。最初,第 个盒子包含 个球。
你将重复以下操作 次:
- 均匀随机地从 个盒子中选择一个(每次独立选择)。向所选盒子中添加一个球。
令 表示在 次操作后第 个盒子中的球数,而 得分 为所有球数的乘积,即 。
求得分的期望值对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
3 1
1 2 3
Sample Output 1
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 .
Sample Input 2
2 2
1 2
Sample Output 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 .
Sample Input 3
10 1000000000
998244350 998244351 998244352 998244353 998244354 998244355 998244356 998244357 998244358 998244359
Sample Output 3
138512322
update @ 2024/3/10 10:05:26