atcoder#ABC287F. [ABC287F] Components
[ABC287F] Components
Score : points
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 S be the subset of the vertices of a graph G; then the subgraph of G induced by S is a graph whose vertex set is S and whose edge set consists of all edges of G whose both ends are contained in S.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 .
4
1 2
2 3
3 4
10
5
0
0
The induced subgraph will have two connected components in the following five cases and one in the others.
2
1 2
3
0
10
3 4
3 6
6 9
1 3
2 4
5 6
6 10
1 8
5 7
140
281
352
195
52
3
0
0
0
0