Count the K-vertex subsets of a tree in which every chosen vertex is adjacent to at least one other chosen vertex, modulo 1000000007.
Medium7TreeDynamic programmingCombinatoricsNo attempts yetTime limit5sMemory limit512 MBA 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 N 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 K huntsmen climbs a different set of stands every day and watches the wildlife. The conditions are these.
Find how many days the group needs in order to try every possible set of stands.
The input holds several test cases and runs to the end of the input.
The first line of a test case has two integers N and K separated by a space (2≤K≤N≤200). N is the number of tree stands and K is the size of the group. The stands are labeled 1 through N.
Then come N−1 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.
For each test case print the number of days the group spends in the tree stands, one line per case. Print the answer modulo 1000000007.