QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#9840. 树的划分

统计

给定一棵有 $n$ 个顶点的树,顶点编号为 $1$ 到 $n$。注意,删除 $x-1$ 条边后,树将变为 $x$ 个连通分量。

要求在删除边后,每个连通分量中顶点的编号集合必须是一个连续区间。也就是说,若记某个连通分量中顶点编号的最小值为 $l$,最大值为 $r$,则所有编号在 $[l, r]$ 范围内的顶点都必须属于该连通分量。

现在对于 $x = 1, 2, \dots, k$,你需要计算删除边的方案数。如果两种方案中至少有一条边在一种方案中被删除而在另一种方案中被保留,则认为这两种方案不同。你只需要输出答案对 $998244353$ 取模的结果。

输入格式

第一行包含两个整数 $n$ ($1 \le n \le 2 \cdot 10^5$) 和 $k$ ($1 \le k \le \min(n, 400)$)。

接下来的 $n-1$ 行,每行包含两个整数 $x, y$ ($1 \le x, y \le n, x \neq y$),表示一条边 $(x, y)$。

输出格式

输出 $k$ 行,每行一个整数,表示对应 $x$ 的答案对 $998244353$ 取模的结果。

样例

输入 1

4 3
1 2
2 3
2 4

输出 1

1
2
2

输入 2

7 7
2 5
3 6
4 5
5 1
1 6
6 7

输出 2

1
1
0
0
1
2
1

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.