PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SRD0000134. Các đường đi rời đỉnh trên cây (You Are Given a Tree)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Các đường đi rời đỉnh trên cây (You Are Given a Tree)

You Are Given a Tree

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an undirected tree of nn vertices labeled 11 through nn. A simple path never repeats a vertex. In this problem, the length of a path is its number of vertices, not its number of edges.

A set of paths is valid for kk if every path contains exactly kk vertices and no vertex belongs to more than one selected path, including path endpoints. Some vertices may remain unused.

For each k=1,2,…,nk=1,2,\ldots,n, find the maximum possible number of paths in a valid set for kk.

Input

  • The first line contains integer nn, the number of vertices.
  • Each of the next n−1n-1 lines contains integers u,vu,v describing an undirected edge of the tree.

Output

Print exactly nn space-separated integers in one line, in increasing order of kk. The kk-th integer is the largest number of vertex-disjoint paths, each containing exactly kk vertices.

Subtasks

  • Subtask 1 (10 points): 2≤n≤302\le n\le30; the graph is an undirected connected acyclic graph with nn vertices and exactly n−1n-1 edges; on each edge 1≤u,v≤n1\le u,v\le n and u≠vu\ne v.
  • Subtask 2 (20 points): 2≤n≤3 0002\le n\le3\,000; the graph is an undirected connected acyclic graph with nn vertices and exactly n−1n-1 edges; on each edge 1≤u,v≤n1\le u,v\le n and u≠vu\ne v.
  • Subtask 3 (30 points): 2≤n≤20 0002\le n\le20\,000; the graph is an undirected connected acyclic graph with nn vertices and exactly n−1n-1 edges; on each edge 1≤u,v≤n1\le u,v\le n and u≠vu\ne v.
  • Subtask 4 (40 points): 2≤n≤100 0002\le n\le100\,000; the graph is an undirected connected acyclic graph with nn vertices and exactly n−1n-1 edges; on each edge 1≤u,v≤n1\le u,v\le n and u≠vu\ne v.

Examples

Example 1

Input

7
1 2
2 3
3 4
4 5
5 6
6 7

Output

7 3 2 1 1 1 1

Explanation

The tree is a chain with seven vertices. For k=1k=1 we can select seven one-vertex paths. For k=2k=2, choose [1,2][1,2], [3,4][3,4], [5,6][5,6]; a fourth would need eight vertices. For k=3k=3, choose [1,2,3][1,2,3] and [4,5,6][4,5,6]. For every 4≤k≤74\le k\le7, at most one path fits and at least one path of that length exists.

Example 2

Input

6
1 2
2 3
2 4
1 5
5 6

Output

6 2 2 1 1 0

Explanation

For k=1k=1, all six vertices can be selected. For k=2k=2, use paths 3−23-2 and 1−51-5; no three disjoint two-vertex paths exist. For k=3k=3, paths 3−2−43-2-4 and 1−5−61-5-6 are disjoint. The longest simple path contains five vertices, for example 3−2−1−5−63-2-1-5-6, so the answer for k=6k=6 is zero.