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

Common Board

Wrong Answer. What's wrong in my program? I'm sure that i'm right! №1024
Posted by Nikitoz68 24 Feb 2011 00:51
#include <cstdio>


using namespace std;

/*
 *
 */
 int main()
{


    unsigned int k = 0;
     unsigned int i;
     unsigned int n;
    scanf("%u",&n);
    unsigned int mas1[1000],mas2[1000];
    for(i = 1;i<=n;i+=1)
    { scanf("%u",&mas1[i]);
     mas2[i] = mas1[i];
    }
    unsigned int a = 0;
    unsigned int s = 0;
    unsigned int m = 0;
   do
   {
       for(int 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[s];
    }
     if ( k == n) { m=1;} else {k = 0;}
    a+=1;
   } while (m!=1);
    printf("%u\n",a);
   return 0;
}