atcoder#ABC231G. [ABC231G] Balls in Boxes

[ABC231G] Balls in Boxes

Score : 600600 points

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.

3 1
1 2 3
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.

2 2
1 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}.

10 1000000000
998244350 998244351 998244352 998244353 998244354 998244355 998244356 998244357 998244358 998244359
138512322