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

No subject
Posted by Happybird 26 Jan 2003 08:37
(1)
0 1 -> 1 wait
2 3-> 5 wait print 1
3 4-> 7 wait print 5
.
.
(2)
0 1 ->1  wait
4 5 -> 9 #1 wait
4 5 ->9 #2 wait
4 5 -> 9 #3  wait
2 2 ->4  wait  <- now- printf '1' & print '9' for 3
.
.
(3)
0 1 ->1 wait
4 5 -> 9 #1 wait
4 5 ->9 #2 wait
4 5 -> 9 #3  wait
5 5 ->10  wait <- now- printf 1+1=2 & print '0' for 3
.
.
.

And this my program ,Who can tell why I got WA?
var
  X,Y,save:byte;
  N,I,j,mark:longint;
  start:boolean;
begin
  readln(N);
  mark:=0;start:=true;
  for i:=1 to N do begin
    readln(x,y);
    if start and(x+y=0) then continue
                        else start:=false;
    if mark=0 then begin save:=x+y;inc(mark); end
              else if x+y<9 then begin
                                     write(save);
                                     for j:=1 to mark-1 do write(9);
                                     save:=x+y;mark:=1;
                                 end
                   else if x+y=9 then inc(mark)
                        else begin
                               write(save+1);
                               for j:=1 to mark-1 do write(0);
                               save:=x+y-10;mark:=1;
                             end;
  end;
  write(save);
  for j:=1 to mark-1 do write(9);
  writeln;
end.