#18998: _c++


allen22edu@gmail.com (陳倫倫)

學校 : 不指定學校
編號 : 100023
來源 : [1.170.141.106]
最後登入時間 :
2020-01-02 20:20:44

#include <iostream>

using namespace std;

int main()
{
int a,b[50000],d=0,e=0,f;
cin>>a;
for(int c=0;c<a;c++)
{
cin>>b[c];
}
for(int c=0;c<a;c++)
{
if(b[c]!=-1)
{for(d=b[c];d!=-1;)
{
f=d;
d=b[d];
b[f]=-1;

}e++;


}
}cout<<e<<endl;
return 0;
}