#11034. [CERC2017] Justified Jungle

[CERC2017] Justified Jungle

[CERC2017] Justified Jungle

题目描述

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 GG consisting of n nodes, find all positive integers kk such that a justified forest can be obtained by erasing exactly kk edges from GG. Note that erasing an edge never erases any nodes. In particular when we erase all n−1n - 1 edges from GG, we obtain a justified forest consisting of nn 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.
8
1 2
2 3
1 4
4 5
6 7
8 3
7 3
1 3 7

提示

(暂无提示) 标签: P4748|2017|ICPC|CERC

来源

P4748|[CERC2017] Justified Jungle