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

Help!!! Why I get WA??
Posted by Yukhnovskiy Yuriy 4 Apr 2002 18:51
Here is my code.
Somebody please help me to find a mistake!


Program n1048;
Var
   A:Array [1..500000] Of Byte;
   n,i:Longint;
   k,x1,y1,x2,y2:byte;
Begin
     Readln(N);
     If (n mod 2)<>0 Then
     Begin
          Readln(x1,y1);
          a[1]:=x1+y1;
          For i:=1 To (n div 2)
          Do Begin
             Readln(X1,Y1);Readln(x2,y2);
             a[i+1]:=x1*10+x2+y1*10+y2;
          End;
          k:=0;
          For I:=((n div 2) +1) DOWnto 1
          Do Begin
             y1:=a[i];
             a[i]:=(y1+k) mod 100;
             k:=(y1+k) div 100;
          End;
          Write(a[1]);
          For i:=2 To ((n div 2)+1) Do
              If a[i]<>0 Then Write(a[i])
              Else Write(a[i],a[i]);
     End;
     If (n mod 2)=0 Then
     Begin
          For i:=1 To (n div 2)
          Do Begin
             Readln(X1,Y1);Readln(x2,y2);
             a[i]:=x1*10+x2+y1*10+y2;
          End;
          k:=0;
          For I:=(n div 2) DOWnto 1
          Do Begin
             y1:=a[i];
             a[i]:=(y1+k) mod 100;
             k:=(y1+k) div 100;
          End;
          For i:=1 To (n div 2) Do
              If a[i]<>0 Then Write(a[i])
                 Else Write(a[i],a[i]);
     End;
     Readln;
End.
Re: Help!!! Why I get WA??
Posted by LiangHonghao 7 Apr 2002 16:07
Here is a Test
4
9 0
9 0
9 0
1 9
The Right Answer is 10000
Your Answer is 0000
Do You Test You Program Before Submit It?:)
Re: Help!!! Why I get WA??
Posted by Vesper 22 Apr 2004 13:13
They say the length of a sum never exceeds N, so your test is wrong. But still, take that in mind.