atcoder#ARC133F. [ARC133F] Random Transition

[ARC133F] Random Transition

Score : 11001100 points

Problem Statement

Given is an integer NN.

Snuke is going to do the procedure below.

  • Let xx be a variable and initialize it with a random integer between 00 and NN (inclusive). For each 0iN0 \leq i \leq N, x=ix=i is chosen with probability Ai/109A_i/10^9.
  • Repeat the following operation KK times.- With probability x/Nx/N, decrease the value of xx by 11; with probability 1x/N1-x/N, increase it by 11. (Here, note that xx will still be between 00 and NN after the operation.)
  • With probability x/Nx/N, decrease the value of xx by 11; with probability 1x/N1-x/N, increase it by 11. (Here, note that xx will still be between 00 and NN after the operation.)

For each i=0,1,,Ni=0,1,\cdots,N, find the probability, modulo 998244353998244353, that x=ix=i after the procedure.

Definition of probability modulo $998244353$

It can be proved that the sought probabilities are always rational numbers. Additionally, under the Constraints of this problem, when representing each of them as an irreducible fraction PQ\frac{P}{Q}, it can be proved that Q0(mod998244353)Q \neq 0 \pmod{998244353}. Thus, there uniquely exists an integer RR such that $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$. Answer with this RR.

Constraints

  • 1N1000001 \leq N \leq 100000
  • 0Ai0 \leq A_i
  • 0iNAi=109\sum_{0 \leq i \leq N}A_i = 10^9
  • 1K1091 \leq K \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

A0A_0 A1A_1 \cdots ANA_N

Output

For each i=0,1,,Ni=0,1,\cdots,N, print the probability, modulo 998244353998244353, that x=ix=i after the procedure.

2 1
0 1000000000 0
499122177 0 499122177

First, xx is always initialized with x=1x=1. In the subsequent operation, the value of xx is decreased by 11 with probability 1/21/2 and increased by 11 with probability 1/21/2. Eventually, we will have x=0,1,2x=0,1,2 with probabilities 1/2,0,1/21/2,0,1/2, respectively.

4 2
200000000 200000000 200000000 200000000 200000000
723727156 598946612 349385524 598946612 723727156
10 100
21265166 263511538 35931763 26849698 108140810 134702248 36774526 147099145 58335759 4118743 163270604
505314898 24510700 872096939 107940764 808162829 831195162 314651262 535843032 665830283 627881537 696038713