AT_abc409_g [ABC409G] Accumulation of Wealth
Description
You are given an integer $ N \geq 2 $ and an integer $ P $ between $ 0 $ and $ 100 $ , inclusive. Let $ p=P/100 $ .
There is a sequence $ A $ . Initially, the length of $ A $ is $ 1 $ , and its only element is $ 1 $ .
The following operation is repeated $ N-1 $ times on sequence $ A $ :
- Let $ m $ be the smallest positive integer that does not appear in $ A $ . With probability $ p $ , perform operation $ 1 $ ; with probability $ 1-p $ , perform operation $ 2 $ :
- Operation $ 1 $ : Append $ m $ to the end of $ A $ .
- Operation $ 2 $ : Let $ c_1,c_2,\dots,c_{m-1} $ be the number of times $ 1,2,\dots,m-1 $ appear in $ A $ , respectively. Choose an integer $ k $ between $ 1 $ and $ m-1 $ , inclusive, with probability proportional to $ c_k $ . That is, choose $ k $ with probability $ c_k/\sum_{j=1}^{m-1} c_j $ . Then, append $ k $ to the end of $ A $ .
For each $ k=1,2,\dots,N $ , find the expected number of occurrences of $ k $ in $ A $ after $ N-1 $ operations, modulo $ 998244353 $ .
Definition of expected value modulo $ 998244353 $ It can be proved that the expected value you seek is always a rational number. Also, under the constraints of this problem, it can be proved that when this value is expressed as an irreducible fraction $ \frac{P}{Q} $ , we have $ Q \neq 0 \pmod{998244353} $ . Therefore, there is a unique integer $ R $ such that $ R \times Q \equiv P \pmod{998244353} $ and $ 0 \leq R \lt 998244353 $ . Output this $ R $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ P $
Output Format
Output $ N $ lines. The $ k $ -th $ (1\leq k \leq N) $ line should contain the expected number of occurrences of $ k $ in $ A $ after the operations, modulo $ 998244353 $ .
Explanation/Hint
### Sample Explanation 1
The operations proceed as follows:
- Initially, $ A=(1) $ .
- $ 1 $ st operation: It becomes $ A=(1,2) $ with probability $ 1/2 $ , and $ A=(1,1) $ with probability $ 1/2 $ .
- $ 2 $ nd operation:
- If $ A=(1,2) $ , it becomes $ A=(1,2,3) $ with probability $ 1/2 $ , $ A=(1,2,1) $ with probability $ 1/4 $ , and $ A=(1,2,2) $ with probability $ 1/4 $ .
- If $ A=(1,1) $ , it becomes $ A=(1,1,2) $ with probability $ 1/2 $ , and $ A=(1,1,1) $ with probability $ 1/2 $ .
The expected numbers of occurrences of $ 1,2,3 $ in the final $ A $ are $ \frac{15}{8}, \frac{7}{8}, \frac{1}{4} $ , respectively.
### Constraints
- $ 2 \leq N \leq 10^5 $
- $ 0 \leq P \leq 100 $
- All input values are integers.