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

建议使用的浏览器:

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

2270:How Many Friends Will Be Together With You

题目描述
One day dandelion and her friends decides to play outside. As there are so many people , they decide to divide into several parts . Dandelion wants to know how many friends will be together with her. The way they use to divide is : everyone can choose one people to join in her group, Such as if A chooses B to join in her group , then B will leave the group she is in now , and joins in the group that A is in . One can also choose some people who has already in her group. All of dandelion抯 friends are expressed as an integer 2,3... n and dandelion is expressed as 1.The choosing work begins from dandelion then the friend who are signed as 2 ?until the friend who are signed as n .
输入解释
Each case begins with an integer n, (0<n<=1000000) stands for the number of people.
Then follows n lines , the i+1 line contains an integer p, stands for people who are signed as i chooses the one who are signed as p to join in her group.
输出解释
The output contains one line for each data set : the number of friends will be together with dandelion at last .
输入样例
3
3
3
1
3
2
1
2
输出样例
2
0

提示
Hint
For the second case , the group is (1)(2)(3) at first , then (1,2)(3) after dandelion抯 picking , then ( 1 , 2 ) ( 3) , then (1) (2 ,3). So at last , no other people is together with dandelion.
来自杭电HDUOJ的附加信息
Author dandelion
Recommend lcy

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

源链接: HDU-2270

最后修改于 2020-10-25T22:52:01+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)