|
|
вернуться в форумWA №9 What's wrong? who can tell me plz? #include <cstdio> using namespace std; /* * */ int main() { long long k = 0; long long i; long long unsigned n; scanf("%llu",&n); long long unsigned mas1[1000]; long long unsigned mas2[1000]; for(i = 1;i<=n;i+=1) { scanf("%llu",&mas1[i]); mas2[i] = mas1[i]; } long long unsigned a = 0; long long s = 0; long long m = 0; do { for(long long j = 1;j<=n;j+=1) { if (j == mas2[j]){ k+=1;} } for(i = 1;i<=n;i+=1) { s = mas2[i]; mas2[i] = mas1[mas2[i]]; } if ( k == n) { m=1;} else {k = 0;} a+=1; } while (m!=1); printf("%llu\n",a); return 0; } |
|
|