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 1110. Power

Why I got WA.HELP!!!!!!!!!!!!!!!!!!!!!!
Posted by kkk 18 Apr 2002 16:38
#include<stdio.h>
main()
{
   int M,N,Y,i,j,k,a[999],state;
   long b[750],temp;
   state=0;
   temp=0;
   for(i=0;i<999;i++)
    a[i]=0;
   scanf("%d%d%d",&N,&M,&Y);
   if(Y==1)
      {
    printf("1 ");
    state=1;
      }
   for(i=2;i<M;i++)
      {
    temp=0;
    for(k=0;k<750;k++)
         b[k]=0;
    j=N;
    b[749]=i;
    while(j>1){
           for(k=749;k>=0;k--)
              {
            if(b[k])
            {
              b[k]*=i;
              if(b[k]>=10000)
                {
                  b[k-1]+=b[k]/10000;
                  b[k]=b[k]%10000;
                 }
             }
             else break;
            }
             j--;
           }

     for(k=0;k<750;k++)
       { if(!b[k])
        continue;
       }
      for(k=k-1;k<750;k++)
      {
         temp=(b[k]+10000*temp)%M;
        }
     if(temp==Y)
         {
         a[i]=1;
         state=1;
         }
     }
     for(i=2;i<M;i++)
       {
     if(a[i]==1)
     {
       printf("%d",i);
       break;
      }
    }
       i++;
    for(;i<M;i++)
    {
      if(a[i]==1)
         printf(" %d",i);
     }
  if(!state)printf("-1");
}
Re: Why I got WA.HELP!!!!!!!!!!!!!!!!!!!!!!
Posted by Zhihua Lai 28 Sep 2006 17:44
Too complicated