ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1024. Permutations

WA №9 What's wrong? who can tell me plz?
Posted by Nikitoz68 24 Feb 2011 02:56
#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;
}