#abc231g. G - Balls in Boxes

G - Balls in Boxes

Score : 600600 points

问题描述

我们有 NN 个编号为 11NN 的盒子。最初,第 ii 个盒子包含 AiA_i 个球。

你将重复以下操作 KK 次:

  • 均匀随机地从 NN 个盒子中选择一个(每次独立选择)。向所选盒子中添加一个球。

BiB_i 表示在 KK 次操作后第 ii 个盒子中的球数,而 得分 为所有球数的乘积,即 i=1NBi\prod_{i=1}^{N}B_i

求得分的期望值对 998244353998244353 取模的结果。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have NN boxes numbered 11 to NN. Initially, Box ii contains AiA_i balls.

You will repeat the following operation KK times.

  • Choose one box out of the NN uniformly at random (each time independently). Add one ball to the chosen box.

Let BiB_i be the number of balls in Box ii after the KK operations, and the score be the product of the numbers of balls, i=1NBi\prod_{i=1}^{N}B_i.

Find the expected value of the score modulo 998244353998244353.

Notes

When the expected value in question is represented as an irreducible fraction p/qp/q, there uniquely exists an integer rr such that rqp(mod998244353)rq\equiv p \pmod{998244353} and 0r<9982443530\leq r < 998244353 under the Constraints of this problem. This rr is the value we seek.

Constraints

  • 1N10001 \leq N \leq 1000
  • 1K1091 \leq K \leq 10^9
  • 0Ai1090 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

NN KK

A1A_1 \ldots ANA_N

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 11 in the operation, 2×2×3=122\times 2\times 3=12.
  • When choosing Box 22 in the operation, 1×3×3=91\times 3\times 3=9.
  • When choosing Box 33 in the operation, 1×2×4=81\times 2\times 4=8.

Therefore, the expected value in question is 13(12+9+8)=293\frac{1}{3}(12+9+8)=\frac{29}{3}. This value modulo 998244353998244353 is 665496245665496245.

Sample Input 2

2 2
1 2

Sample Output 2

499122182

After the operations, the score will be as follows.

  • When choosing Box 11 in the first operation and Box 11 in the second, 3×2=63\times 2=6.
  • When choosing Box 11 in the first operation and Box 22 in the second, 2×3=62\times 3=6.
  • When choosing Box 22 in the first operation and Box 11 in the second, 2×3=62\times 3=6.
  • When choosing Box 22 in the first operation and Box 22 in the second, 1×4=41\times 4=4.

Therefore, the expected value in question is 14(6+6+6+4)=112\frac{1}{4}(6+6+6+4)=\frac{11}{2}.

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