트리 위에 K마리의 소를 서로 다른 정점에 배치할 때, 빈 인접 정점으로 소를 옮겨 서로 도달할 수 있는 배치들을 같은 부류로 묶는다. 각 K마다 배치 부류의 개수를 10^9+7로 나눈 나머지를 구한다.
어려움9트리DFS조합론동적 계획법아직 제출이 없습니다시간 제한1초메모리 제한512 MBThe N cows of Farmer John's Circus (1≤N≤105) are preparing their upcoming acts. The acts all take place on a tree with vertices labeled 1…N. The "starting state" of an act is defined by a number 1≤K≤N and an assignment of cows 1…K to the vertices of the tree, so that no two cows are located at the same vertex.
In an act, the cows make an arbitrarily large number of "moves." In a move, a single cow moves from her current vertex to an unoccupied adjacent vertex. Two starting states are said to be equivalent if one may be reached from the other by some sequence of moves.
For each 1≤K≤N, help the cows determine the number of equivalence classes of starting states: that is, the maximum number of starting states they can pick such that no two are equivalent. Since these numbers may be very large, output their remainders modulo 109+7.
Line 1 contains N.
Lines 2≤i≤N each contain two integers a_i and b_i denoting an edge between a_i and b_i in the tree.
For each 1≤i≤N, the i-th line of output should contain the answer for K=i modulo 109+7.