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 1495. One-two, One-two 2

WA #10 , can you help me???
Posted by datct0407 30 Oct 2008 07:57
#include <stdio.h>

#define maxn 1000001
        long n;
       short result[31],b[maxn];
       int tr[maxn];
      long count,i,j;

main()
{
       scanf("%ld",&n);
      for (i=0;i<n;i++) b[i]=0;
      b[1%n]=1;
      tr[1%n]=0;
      if (n!=1) b[2%n]=2;
      tr[2%n]=0;
      count=1;
       while (b[0]==0 && count <30)
      {
          count++;
          for (i=1;i<n;i++)
         if  (b[i]!=0)
         {
             if (b[(i*10+1)%n]==0)
            {
                b[(i*10+1)%n]=1;
               tr[(i*10+1)%n]=i;
            };
             if (b[(i*10+2)%n]==0)
            {
                b[(i*10+2)%n]=2;
               tr[(i*10+2)%n]=i;
            };
         }
      }
      if (b[0]==0)
      {
          printf("Impossible");
      }
      else
      {
          i=0;
         j=1;
         result[j]=b[i];
         while (tr[i]!=0)
         {
             i=tr[i];
            j++;
            result[j]=b[i];
         }
         for (i=j;i>0;i--) printf("%d",result[i]);
      }
    getchar();
}
Re: WA #10 , can you help me???
Posted by alp 12 Jan 2017 21:53
74147

21221212122222222
Re: WA #10 , can you help me???
Posted by Arseniy_Pavlov 13 Oct 2019 01:27
When i had wa 10 i found out that my solution on test like 101 gives me 1212 instead of 1111. It doesnt helped me on this test, but i found mistake anyway
Re: WA #10 , can you help me???
Posted by Ade 13 Jan 2023 15:16
thanks a lot!