#P7720. 「EZEC-10」「Byakkai OI 2021」Estahv

「EZEC-10」「Byakkai OI 2021」Estahv

Description

We have infinitely many cells in a row, numbered from left to right as 1,2,1,2,\dots.

You may fill any positive integer kk into each cell, and then you obtain the weight CkC_k.
Here, C0=C1=1C_0=C_1=1, and Ci=j=0i1CjCij1C_i = \sum\limits_{j=0}^{i-1} C_j C_{i-j-1} (i2)(i \ge 2).
The total weight of several cells is defined as the product of their weights.

Now you need to fill numbers into the cells from left to right, until the sum of the filled numbers becomes equal to nn or exceeds nn.
After that, you need to color each filled cell either black or white, satisfying: there do not exist any 22 or more consecutive white cells, the first cell must be black, and the last filled cell must be white.
Then, you need to add an edge between every pair of adjacent filled cells that have the same color, and select a set of cells SS such that any two cells in SS are not connected by an edge (it can be empty).

The weight of a plan is defined as the total weight of all cells.

Given nn, for s=0,1,,ns=0,1,\dots,n, compute the sum of weights over all plans that complete all operations above, such that the sum of the filled numbers is exactly nn, and the number of black cells is ss.
Two plans are different if and only if the number of filled cells is different, or the numbers filled in the corresponding cells are different, or the colors of the corresponding cells are different, or the set SS is different.
Take the result modulo 998244353998244353.

Input Format

The first line contains one positive integer nn.

Output Format

Output one line with n+1n+1 non-negative integers, representing the answers for s=0,1,,ns=0,1,\dots,n.

3
0 16 6 0
8
0 8008 24388 29840 16788 4360 476 16 0

Hint

[Explanation of Sample 11.]

When n=3n=3, there can be 22 or 33 cells.
If there are 22 cells, the filling plans are [1,2][1,2] or [2,1][2,1], and the total weight is 2×C1×C2=42 \times C_1 \times C_2 = 4; the coloring plan is BW, so there must be one black cell; the choices of the set SS are {},{1},{2},{1,2}\{\},\{1\},\{2\},\{1,2\} (cells are indexed by their numbers).
If there are 33 cells, the filling plan is [1,1,1][1,1,1], and the weight is C13=1C_1^3=1; the coloring plan is BBW, so there must be two black cells; the choices of the set SS are {},{1},{2},{3},{1,3},{2,3}\{\},\{1\},\{2\},\{3\},\{1,3\},\{2,3\} (cells are indexed by their numbers).
Here, B means black and W means white.

[Constraints.]

This problem uses bundled tests.

  • Subtask 1 (30 points): n10n\le10.
  • Subtask 2 (20 points): n300n\le300.
  • Subtask 3 (20 points): n5000n \le 5000.
  • Subtask 4 (30 points): no special constraints, time limit is 3.5s3.5s.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5.

Hint

To make it easier for everyone to get points with brute force, here is the result:

$$C_k = \frac1k \binom{2k}{k-1} = \binom{2k-1}{k-1}-\binom{2k-1}{k-2}$$

Translated by ChatGPT 5