QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#11414. Theoretical Complexity

統計

Xiao z gave Xiao m a malicious problem.

Xiao m does not know how to solve it, so she starts writing a brute-force search. Although Xiao z once said: "Theoretical complexity has no direct relationship with runtime efficiency," Xiao m still wants to know the theoretical complexity of her brute-force search. She discovered that the number of search iterations is equivalent to the number of ways to fill numbers into a tree.

This tree has $10^{10^{10}}$ nodes, numbered starting from $1$. Let $r \ge 1$ be a parameter. For a node with index $i$, if $2 \leq i \leq r + 1$, its parent is the node with index $i-1$; if $r + 2 \leq i$, its parent is the node with index $i-2$.

The figure below shows a tree with $r=4$, showing only a small part at the top. Each circle represents a node, and the number next to the circle is the node's index.

Now, Xiao m wants to fill each node with a number. The filling must satisfy three conditions:

  1. The filled numbers must be non-negative integers.
  2. For the $i$-th node ($i \ge 2$), the number filled in its parent must be no less than the number filled in the node itself.
  3. The sum of all filled numbers must be exactly $n$.

Xiao m wants to know, for each $n \in [1, N]$, how many ways there are to fill the numbers. However, she also realizes that the number of ways is very large, so you only need to output the answer modulo $998244353$.

Input

A single line containing two integers $N$ and $r$, representing the maximum sum of the numbers and the shape of the tree, respectively.

Output

A single line containing $N$ integers, where the $i$-th integer represents the number of ways for $n=i$, modulo $998244353$.

Examples

Input 1

9 4

Output 1

1 2 3 5 8 14 22 36 56

Note 1

For $n=5$, the possible ways are:

  1. $[5]$
  2. $[4,1]$
  3. $[3,2]$
  4. $[3,1,1]$
  5. $[2,2,1]$
  6. $[2,1,1,1]$
  7. $[1,1,1,1,1]$
  8. $[1,1,1,1,0,1]$

Here, the $i$-th number represents the value filled in the $i$-th node, and any nodes not listed are filled with $0$.

Input 2

See attachment.

Constraints

Subtask $N \leq$ $r \leq$ Score
$1$ $100$ $20$ $10$
$2$ $1000$ $100$ $20$
$3$ $500000$ $1$ $10$
$4$ $2$ $30$
$5$ $500$ $30$

For all data, $1 \leq N \leq 500000, 1 \leq r \leq 500$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.