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 1048. Superlong Sums

Why I got WA?Is there some special test data I got WA?Who can give me a hand?Thank you!
Posted by Нфиє 12 Feb 2003 06:16
My program:

#include<stdio.h>
long n9,n;
int a,b;
void main(void)
  {
    int i,j,l;
    scanf("%ld",&n);
    n9=0;
    l=-1;
    for (i=0;i<n;i++)
      {
    scanf("%d %d",&a,&b);
    if (a+b==9) n9++;
    if (n9==0)
      {
        if (l!=-1) printf("%d",(a+b)/10+l);
        if (l==-1 && a+b>9) printf("%d",(a+b)/10);
        l=(a+b)%10;
      }
    else if (n9!=0 && a+b<9)
      {
        printf("%d",l);
        for (j=0;j<n9;j++) printf("9");
        n9=0;
        l=a+b;
      }
    else if (n9!=0 && a+b>9)
      {
        printf("%d",l+1);
        for (j=0;j<n9;j++) printf("0");
        n9=0;
        printf("%d",a+b-10);
        l=-1;
      }
      }
    if (n9!=1) for (i=0;i<n9;i++) printf("9");
    if (l!=-1) printf("%d\n",l);
    if (n==0) printf("%d\n",0);
  }

It is writed by C++,and got WA.
If there is some special test data makes my program got WA.May I have
it? Thank you!
Re: Why I got WA?Is there some special test data I got WA?Who can give me a hand?Thank you!
Posted by Calin Ciutu (ciutu@go.ro) 12 Feb 2003 15:27
Try these tests :

1 + 8
2 + 7
14 + 5
46 + 3
58 + 1
.
.
.
.
and so on .

If you still get WA send me an email . ciutu@go.ro
Re: Why I got WA?Is there some special test data I got WA?Who can give me a hand?Thank you!
Posted by &#1053;&#1092;&#1080;&#1108; 14 Feb 2003 15:28
> Try these tests :
>
> 1 + 8
> 2 + 7
> 14 + 5
> 46 + 3
> 58 + 1
> .
> .
> .
> .
> and so on .
>
> If you still get WA send me an email . ciutu@go.ro
I accpet these tests,but I still got WA!?
Re: Why I got WA?Is there some special test data I got WA?Who can give me a hand?Thank you!
Posted by &#1053;&#1092;&#1080;&#1108; 14 Feb 2003 15:37
> > Try these tests :
> >
> > 1 + 8
> > 2 + 7
> > 14 + 5
> > 46 + 3
> > 58 + 1
> > .
> > .
> > .
> > .
> > and so on .
> >
> > If you still get WA send me an email . ciutu@go.ro
> I accpet these tests,but I still got WA!?
my program:

#include<stdio.h>
long n9,n;
int a,b;
void main(void)
  {
    int i,j,l;
    scanf("%ld",&n);
    n9=0;
    l=-1;
    for (i=0;i<n;i++)
      {
    scanf("%d %d",&a,&b);
    if (a+b==9) n9++;
    if (n9==0)
      {
        if (l==-1) if (a+b>9) printf("%d",(a+b)/10);
        if (l!=-1 && a+b>9) printf("%d",l+((a+b)/10));
        if (l!=-1 && a+b<9) printf("%d",l);
        l=(a+b)%10;
      }
    else if (n9!=0 && a+b<9)
      {
        printf("%d",l);
        for (j=0;j<n9;j++) printf("9");
        n9=0;
      }
    else if (n9!=0 && a+b>9)
      {
        printf("%d",l+1);
        for (j=1;j<n9;j++) printf("0");
        n9=0;
      }
      }
    if (l!=-1) printf("%d",l); else printf("0");
    if (n9!=0) for (i=0;i<n9;i++) printf("9");
  }