Sugoroku 6

AtCoder
IDabc439_g
Time10000ms
Memory256MB
Difficulty
> Happy New Year! When it comes to indoor play on New Year's, it's sugoroku! There is a sugoroku board consisting of $N+1$ squares: squares $0$, square $1$, $\dots$, square $N$. There is an $M$\-sided die (dice) that produces positive integers $A_1, A_2, \dots, A_M$ with equal probability. Here, $A_1, A_2, \dots, A_M$ are distinct. Person $1$, person $2$, $\dots$, person $L$ will play a game using this board. The game proceeds as follows: * Initially, place $L$ pieces, piece $1$, piece $2$, $\dots$, piece $L$, on square $0$. * Turns come around in numerical order starting with person $1$. Strictly speaking, after person $i$'s turn, the turn goes to person $(i \bmod L) + 1$. Each person performs the following operation on their turn: * Let $i$ be the number of the person whose turn it is. Roll the die. Let $x$ be the square where piece $i$ is located and $y$ be the integer that came up on the die, and move piece $i$ to square $\min(N, x+y)$. * The first person to place their numbered piece on square $N$ wins, and the other people lose. For $i =1,2,\dots,L$, find the probability, modulo $998244353$, that person $i$ wins. What is probability $\text{mod }998244353$? It can be proved that the probability to be found is always a rational number. Also, under the constraints of this problem, when the value is expressed as $\frac{P}{Q}$ using two coprime integers $P$ and $Q$, it can be proved that there exists exactly one integer $R$ that satisfies $R \times Q \equiv P\pmod{998244353}$ and $0 \leq R \lt 998244353$. Find this $R$. ## Constraints * $1 \leq N \leq 2.5 \times 10^5$ * $1 \leq M \leq N$ * $2 \leq L \leq 2.5 \times 10^5$ * $1 \leq A_1 \lt A_2 \lt \dots \lt A_M \leq N$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $L$ $A_1$ $A_2$ $\dots$ $A_M$ [samples]
Samples
Input #1
2 2 3
1 2
Output #1
374341633
748683265
873463809

Person $1$ wins with the probability $\frac{5}{8}$, person $2$ wins with the probability $\frac{1}{4}$, and person $3$ wins with the probability $\frac{1}{8}$.
Input #2
100 2 4
20 26
Output #2
164734081
939753473
943409153
946836353
Input #3
123456 12 10
21994 29598 47718 59035 69293 73766 74148 76721 98917 104184 120533 122441
Output #3
580013367
81975961
178650340
610261473
14826260
541995390
307779600
913805572
76177928
687491522
API Response (JSON)
{
  "problem": {
    "name": "Sugoroku 6",
    "description": {
      "content": "> Happy New Year! When it comes to indoor play on New Year's, it's sugoroku! There is a sugoroku board consisting of $N+1$ squares: squares $0$, square $1$, $\\dots$, square $N$.   There is an $M$\\-si",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 10000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc439_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "> Happy New Year! When it comes to indoor play on New Year's, it's sugoroku!\n\nThere is a sugoroku board consisting of $N+1$ squares: squares $0$, square $1$, $\\dots$, square $N$.  \nThere is an $M$\\-si...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments