#abc287f. F - Components
F - Components
Score : points
问题描述
你得到一棵有 个顶点的树。这些顶点按从 到 编号,第 条边连接顶点 和顶点 。
对于每个 解决以下问题:
- 树的顶点存在 个非空子集 。求满足由 引出的子图恰好有 个连通分量的 的数量,并对结果取模 。
什么是引出子图?设 是图 的顶点集合的一个子集;那么由 引出的 的子图是一个顶点集合为 ,且边集包含所有两端点均在 中的 的边的图。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a tree with vertices. The vertices are numbered through , and the -th edge connects vertex and vertex .
Solve the following problem for each :
- There are non-empty subsets of the tree's vertices. Find the number, modulo , of such that the subgraph induced by has exactly connected components.
What is an induced subgraph? Let be the subset of the vertices of a graph ; then the subgraph of induced by is a graph whose vertex set is and whose edge set consists of all edges of whose both ends are contained in .
Constraints
- The given graph is a tree.
Input
The input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer for .
Sample Input 1
4
1 2
2 3
3 4
Sample Output 1
10
5
0
0
The induced subgraph will have two connected components in the following five cases and one in the others.
Sample Input 2
2
1 2
Sample Output 2
3
0
Sample Input 3
10
3 4
3 6
6 9
1 3
2 4
5 6
6 10
1 8
5 7
Sample Output 3
140
281
352
195
52
3
0
0
0
0
update @ 2024/3/10 12:00:34