[CERC2017] Justified Jungle

题意翻译

### 题目描述 给你一棵包含 $ N $ 个节点的树 $ (N \leq 10^6) $,求可以通过删除树上的多少条边,使得得到的森林满足其中所有的树都包含相同数量的节点。输出所有合法的删边数量。 合法的删边数量 $ k $ 指的是存在至少一种方案,删去了恰好 $ k $ 条边,得到的森林满足其中所有的树都包含相同数量的节点。 ### 输入格式 第一行有一个正整数 $ N $ ,表示树的点数。 接下来 $ N - 1 $ 行,每行两个正整数 $ a , b $ ,表示一条连接点 $ a $ 与点 $ b $ 的无向边。 ### 输出格式 输出一行,包含若干个以空格分隔的正整数,表示所有合法的删边数量。

题目描述

As you probably know, a tree is a graph consisting of $n$ nodes and $n - 1$ undirected edges in which any two nodes are connected by exactly one path. A forest is a graph consisting of one or more trees. In other words, a graph is a forest if every connected component is a tree. A forest is justified if all connected components have the same number of nodes. Given a tree $G$ consisting of n nodes, find all positive integers $k$ such that a justified forest can be obtained by erasing exactly $k$ edges from $G$. Note that erasing an edge never erases any nodes. In particular when we erase all $n - 1$ edges from $G$, we obtain a justified forest consisting of $n$ one-node components.

输入输出格式

输入格式


The first line contains an integer $n(2 \le n \le 1 000 000)$ — the number of nodes in $G$. The $k-th$ of the following $n - 1$ lines contains two different integers $a_k$ and $b_k(1 \le a_k, b_k \le n)$ — the endpoints of the $k-th$ edge.

输出格式


The first line should contain all wanted integers $k$, in increasing order.

输入输出样例

输入样例 #1

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

输出样例 #1

1 3 7