http://acm.hdu.edu.cn/showproblem.php?pid=1232
基本和1856相同,就是最后需要判断一下。。。。。


int count = 0 ;
for (i = 1 ;i <= n;i ++ ) // 其父结点为其本身即可
{
if (FindFa(i) == i) count ++ ;
}
cout << count - 1 << endl;
http://acm.hdu.edu.cn/showproblem.php?pid=1232
基本和1856相同,就是最后需要判断一下。。。。。
int count = 0 ;
for (i = 1 ;i <= n;i ++ ) // 其父结点为其本身即可
{
if (FindFa(i) == i) count ++ ;
}
cout << count - 1 << endl;
转载于:https://my.oschina.net/garyun/blog/602932