Tree Stands
Time limit5sMemory limit512 MB
Count the K-vertex subsets of a tree in which every chosen vertex is adjacent to at least one other chosen vertex, modulo 1000000007.
- Level
Medium7 of 10
- Topics
- Tree, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
A tree stand is a raised wooden platform fixed to a tree. Huntsmen climb tree stands to watch or to shoot their prey.
The huntsmen of this county joined tree stands with narrow straight paths. To damage the forest as little as possible they built the smallest number of paths that still lets anyone walk between any two stands. One stand is visible from another one only when a path joins the two directly.
A group of huntsmen climbs a different set of stands every day and watches the wildlife. The conditions are these.
- Safety rules say that an occupied stand must be visible from at least one other occupied stand, so that the huntsman next door can come to help if something goes wrong.
- At most one huntsman occupies a stand.
- It does not matter which huntsman sits in which stand. Only the set of occupied stands matters.
- The size of the group never changes.
Find how many days the group needs in order to try every possible set of stands.
Input
The input holds several test cases and runs to the end of the input.
The first line of a test case has two integers and separated by a space (). is the number of tree stands and is the size of the group. The stands are labeled through .
Then come lines, one path per line. Each line has the labels of the two stands that the path joins, separated by a space. The order of the two labels on a line and the order of the lines are arbitrary.
Output
For each test case print the number of days the group spends in the tree stands, one line per case. Print the answer modulo .