405830: GYM102133 A Tree Orientation
Memory Limit:64 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
A. Tree Orientationtime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output1 ≤ n ≤ 1000 0 ≤ m ≤ n 1 ≤ ui, vi ≤ n Output
There are different legends for tasks. They can be long or short. They can be boring or funny. They can be understandable or not. You decide: what is this.
Given an undirected tree with n vertices. Find out how many different ways you can orient the edges of the tree so that the result graph will contain exactly m sink vertices. Sink vertex is a vertex with zero outdegree.
InputThe first line of input contains two numbers n (the total number of vertices) and m (required number of sink vertices).
Each of the following n - 1 rows contains a description of the edges, i.e. its ends ui and vi.
You should output an amount of ways to orient the tree modulo 109 + 7.
ExampleInput5 2Output
1 2
2 3
3 4
3 5
8