#P10912. [蓝桥杯 2024 国 B] 数星星
[蓝桥杯 2024 国 B] 数星星
Problem Description
Xiaoming is counting stars on a tree. This tree has nodes . He defines a subgraph on the tree to be a star if and only if satisfies all of the following:
- is a tree.
- There exists a node in whose degree is , where denotes the number of nodes contained in this subgraph.
Two stars are considered different if and only if their node sets are not exactly the same. Xiaoming wants to know how many different stars in this tree have a number of nodes within the interval . Output the answer modulo .
Input Format
The input has a total of lines.
The first line contains a positive integer .
The next lines each contain two positive integers, representing an edge of the tree.
The -th line contains two positive integers .
Output Format
Output a total of line, containing one integer representing the answer.
6
1 2
1 3
2 4
2 5
3 6
3 4
6
Hint
Sample Explanation.
There are stars containing nodes, and their node sets are , , , , .
There is star containing nodes, and its node set is .
Constraints.
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5