atcoder#ARC125F. [ARC125F] Tree Degree Subset Sum
[ARC125F] Tree Degree Subset Sum
Score : points
Problem Statement
Given is a tree with vertices. The vertices are numbered through , and the -th edge connects Vertex and Vertex .
Find the number of pairs of integers that satisfy the following conditions.
- .
- There is a way to choose exactly vertices from the tree so that the sum of their degrees equals .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 2
2 3
6
The following six pairs satisfy the conditions.
, for example, satisfies the condition because choosing Vertex and Vertex achieves the total degree of .
5
1 2
2 3
2 4
4 5
16
10
2 9
8 10
2 10
4 6
5 6
1 8
2 7
3 6
6 8
65