当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5329:Question for the Leader

题目描述
JRY is the leader of a village. He has $n$ lands, and there are $n$ roads connecting them. There is at most one road connecting two lands and all lands are connected.

Now, JRY wants to divided the $n$ lands into $k$ disjoint sets of equal size, satisfying that one can move between any two lands belonging to the same set passing only through lands frome this set.

Furthermore, he wants to know how many $k(1\leq k\leq n)$ he can choose.
输入解释
There are multiple testcases, the sum of $n$ is less then $10^6$.

For each test case, the first line contains one integer $n(1\leq n\leq 10^5)$.

The next line contains $n$ integers, the $i$-th integer $a_i$ means that there is an edge between $i$ and $a_i$. It is guaranteed that the graph doesn't contain self loops and multiple edges.
输出解释
For each testcase print a single integer - the number of ways to choose the integer $k$.
输入样例
6
2 3 4 5 6 1
6
2 4 2 3 4 3
输出样例
4
3
提示
Case 1 : $k$ = 1,2,3,6
Case 2:  $k$ = 1,3,6
来自杭电HDUOJ的附加信息
Author XJZX
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5329

最后修改于 2020-10-25T23:21:45+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 262144/262144K(Java/Others)