|
|
вернуться в форумhow can i make my answer faster ??? ( Code Included ) Послано Hany 1 сен 2003 16:33 how can i make my answer faster ??? my code is ::: #include<stdio.h> #include<iostream.h> main() { int n; cin>>n; int *arr=new int[n]; int *result=new int[n];
for(int i=0;i<n;i++) cin>>arr[i];
int max=1,temp; bool x=true; while(1) { temp=0; for(int i=0;i<n;i++) { temp=i; for(int j=0;j<max;j++) { result[i]=arr[temp]; temp=result[i]-1; } if(result[i]!=i+1) { x=false; break; } } if(x==false) { x=true; max++; continue; } cout<<max<<endl; break; } } |
|
|