|
|
back to boardTLE 11 HELP PLZ !!!!!! #include <cstdio> using namespace std; int main() { int const Q=1001; long long unsigned k = 0,i,n,a=0; scanf("%llu",&n); long long unsigned mas1[Q]; long long unsigned mas2[Q]; for(i = 1;i<=n;i++) { scanf("%llu",&mas1[i]); mas2[i] = mas1[i]; } for(;;) { for(i = 1;i<=n;i++) { if (i == mas2[i]){ k++;} mas2[i] = mas1[mas2[i]]; } a++; if ( k == n) { break;} else {k = 0;} } printf("%llu\n",a); return 0; } |
|
|