No.1886 Sum of Slide Max
タグ : / 解いたユーザー数 92
作問者 :
miscalc
/ テスター :
Problem Statement
For a permutation $P = (P_1, P_2, \ldots, P_N)$ of $(1, 2, \ldots, N)$ and an integer $K$ satisfying $1 \leq K \leq N$, define $f_K(P)$ by the following formula.
$$\displaystyle f_K(P) = \sum_{i = 1}^{N - K + 1} \max \{P_i, P_{i+1}, \ldots, P_{i + K - 1} \}$$
Solve the following problem for each of $K = 1, 2, \ldots, N$.
- There are $N!$ possible permutations $P$. Compute $f_K(P)$ for all of them, and output the sum of these values modulo $998244353$.
Input
$N$
- $N$ is an integer.
- $1 \leq N \leq 2 \times 10^5$
Output
Output $N$ lines. On the $i$-th line, output the answer to the problem for the case $K = i$. Print a newline at the end.
Sample
Sample 1
Input
3
Output
36 32 18
For example, consider the case $K = 2$.
- When $P = (1, 2, 3)$, $f_2(P) = \max\{1, 2\} + \max\{2, 3\} = 2 + 3 = 5$
- When $P = (1, 3, 2)$, $f_2(P) = \max\{1, 3\} + \max\{3, 2\} = 3 + 3 = 6$
- When $P = (2, 1, 3)$, $f_2(P) = \max\{2, 1\} + \max\{1, 3\} = 2 + 3 = 5$
- When $P = (2, 3, 1)$, $f_2(P) = \max\{2, 3\} + \max\{3, 1\} = 3 + 3 = 6$
- When $P = (3, 1, 2)$, $f_2(P) = \max\{3, 1\} + \max\{1, 2\} = 3 + 2 = 5$
- When $P = (3, 2, 1)$, $f_2(P) = \max\{3, 2\} + \max\{2, 1\} = 3 + 2 = 5$
Sample 2
Input
5
Output
1800 1920 1620 1152 600
For example, when $K = 3, P = (4, 1, 2, 5, 3)$, we have $f_3(P) = \max\{4, 1, 2\} + \max\{1, 2, 5\} + \max\{2, 5, 3\} = 4 + 5 + 5 = 14$.
Sample 3
Input
12
Output
427083739 743823315 783415762 911798228 585453527 427083739 748039904 723050469 455899114 12629999 435516917 756797435
Output the values modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。