Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪里错了呢??????!!!!!!!!!!!!!!!#include<iostream> using namespace std; int a[10010]; int vis[10010]; int main() { int t,n,i,k,temp; while(scanf("%d",&t)==1){ for(i=0;i<t;i++){ scanf("%d",&n); int count=0; for(k=0;k<n;k++){ scanf("%d",&temp); a[temp]=k+1; } for(k=0;k<=n;k++) vis[k]=0; for(k=1;k<=n;k++){ if(!vis[k]){ temp=k; while(!vis[temp]){ vis[temp]=1; temp=a[temp]; } count++; } } printf("%d\n",n-count); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator