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 1021. Sacrament of the Sum

Who can help me!!!!!!!!!!!!!!!!!!!!Why I got WA!!!!
Posted by kkk 16 Apr 2002 18:51
#include<stdio.h>
main()
{
/*   freopen("a.in","r",stdin);
   freopen("a.out","w",stdout);*/
   int a,b,k,state;
   long i,j;
   j = 0;
   k = 0;
   state=0;
   scanf("%ld",&i);
   scanf("%d%d",&a,&b);
   if(a+b>=10)
    {
      printf("1");
      k = a + b - 10;
      state=1;
     }
    else if(a + b == 9)
         j++;
      else
      {
      k = a + b;
      state = 1;
      }
    for(;i>1;i--)
      { scanf("%d%d",&a,&b);
    if(a + b >= 10)
      {
        printf("%d",k + 1);
        for(;j>0;j--)
           printf("0");
        k = a + b - 10;
        state = 1;
       }
     else if(a + b == 9)
          j++;
           else{ if(state)
            printf("%d",k);
             k = a + b;
             state = 1;
             for(;j>0;j--)
               printf("9");
             }
    }
    if(state)printf("%d",k);
    for(; j > 0;j--)
      printf("9");
/* fclose(stdin);
 fclose(stdout);*/
 }
Your source is not for problem 1021...
Posted by Vladimir Milenov Vasilev 17 Apr 2002 01:11
> #include<stdio.h>
> main()
> {
> /*   freopen("a.in","r",stdin);
>    freopen("a.out","w",stdout);*/
>    int a,b,k,state;
>    long i,j;
>    j = 0;
>    k = 0;
>    state=0;
>    scanf("%ld",&i);
>    scanf("%d%d",&a,&b);
>    if(a+b>=10)
>     {
>       printf("1");
>       k = a + b - 10;
>       state=1;
>      }
>     else if(a + b == 9)
>          j++;
>       else
>       {
>       k = a + b;
>       state = 1;
>       }
>     for(;i>1;i--)
>       { scanf("%d%d",&a,&b);
>     if(a + b >= 10)
>       {
>         printf("%d",k + 1);
>         for(;j>0;j--)
>            printf("0");
>         k = a + b - 10;
>         state = 1;
>        }
>      else if(a + b == 9)
>           j++;
>            else{ if(state)
>             printf("%d",k);
>              k = a + b;
>              state = 1;
>              for(;j>0;j--)
>                printf("9");
>              }
>     }
>     if(state)printf("%d",k);
>     for(; j > 0;j--)
>       printf("9");
> /* fclose(stdin);
>  fclose(stdout);*/
>  }
...You must be dreaming now.
Posted by LiangHonghao 17 Apr 2002 10:27
It's the program for 1048 SUPERLONG SUM.