#abc207f. F - Tree Patrolling

F - Tree Patrolling

Score : 600600 points

问题描述

你拥有一棵包含 NN 个顶点的树,顶点编号为 11NN。第 ii 条边连接顶点 uiu_i 和顶点 viv_i

你需要选择一些顶点(可能一个都不选)并在其中放置高桥守卫来保护这棵树。放置在顶点 xx 的高桥守卫将守护顶点 xx 本身以及通过边直接与 xx 相连的所有顶点。

共有 2N2^N 种选择顶点放置高桥守卫的方式。其中有多少种方式能够使得恰好有 KK 个顶点被一个或多个高桥守卫守护?

请计算这个计数,并对每种情况下的 K=0,1,,NK=0,1,\ldots,N,将结果模 (109+7)(10^9+7) 后输出。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You have a tree with NN vertices, numbered 11 through NN. The ii-th edge connects Vertex uiu_i and Vertex viv_i.

You will choose some vertices (possibly none) and place a takahashi in each of them to guard the tree. A takahashi placed at Vertex xx will guard xx itself and the vertices directly connected to xx by an edge.

There are 2N2^N ways to choose vertices for placing takahashi. In how many of them will there be exactly KK vertices guarded by one or more takahashi?

Find this count and print it modulo (109+7)(10^9+7) for each K=0,1,,NK=0,1,\ldots,N.

Constraints

  • 1N20001 \leq N \leq 2000
  • 1ui<viN1 \leq u_i \lt v_i \leq N
  • The given graph is a tree.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

u1u_1 v1v_1

u2u_2 v2v_2

\hspace{0.6cm}\vdots

uN1u_{N-1} vN1v_{N-1}

Output

Print N+1N+1 lines. The ii-th line should contain the answer for K=i1K=i-1.

Sample Input 1

3
1 3
1 2

Sample Output 1

1
0
2
5

There are eight ways to choose vertices for placing takahashi, as follows:

  • Place a takahashi at no vertices, guarding no vertices.
  • Place a takahashi at Vertex 11, guarding all vertices.
  • Place a takahashi at Vertex 22, guarding Vertices 11 and 22.
  • Place a takahashi at Vertex 33, guarding Vertices 11 and 33.
  • Place a takahashi at Vertices 11 and 22, guarding all vertices.
  • Place a takahashi at Vertices 11 and 33, guarding all vertices.
  • Place a takahashi at Vertices 22 and 33, guarding all vertices.
  • Place a takahashi at all vertices, guarding all vertices.

Sample Input 2

5
1 3
4 5
1 5
2 3

Sample Output 2

1
0
2
5
7
17

Sample Input 3

10
6 10
1 8
2 7
5 6
3 8
3 4
7 10
4 9
2 8

Sample Output 3

1
0
3
8
15
32
68
110
196
266
325

update @ 2024/3/10 09:21:17