Holi And Tree
Tag(s):

## Algorithms, Depth-first search, Dp, Dynamic Programming, Dynamic programming, Medium-Hard

Problem
Editorial
Analytics

This Holi you need to color the trees.There is a tree having N nodes with 1 as the root.A valid tree is defined as X-specific:

• Every node except the leaf node has exactly X children. Here children means immediate children.

Your task is to compute the minimum number of nodes he should remove from the tree to make the tree X-specific. Find this for all X ranging from 1 to N).

Note: You can remove the nodes which are currently leafs in a single step

Constraints

$1 \le N \le 10^5$

Input

The first line contains one integer N .

The next N−1 lines contains two integers u and v denoting that there is an edge between them.

Output

Print N lines containing the answer.

SAMPLE INPUT
6
1 2
1 3
1 4
4 5
4 6
SAMPLE OUTPUT
3
1
2
5
5
5

Explanation

For X=1 remove nodes $2,3,5$.

For X=2 remove node 2.

For X=3 remove node $5,6$

For X=4,5,6 remove all the nodes except root

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

March Easy '18

OTHER PROBLEMS OF THIS CHALLENGE
• Basic Programming > Implementation
• Math > Number Theory
• Algorithms > Graphs
• Algorithms > Dynamic Programming

?