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 do i always receive OUTPUT LIMIT EXCEEded ??? HELP ME PLEASE THE ALGORITM IS RIGHT COULD YOU CHECK ONLY THE OUTPUT ??? :)
Posted by uuuuuuu 5 Oct 2002 20:26
i'm sure it's correct but i always receive output l e ..... is it
correct to print the part of the answer while reading ???
var
i,j,n,ile,x,y,suma,iled:longint;
begin
readln(n);
repeat
inc(i);
read(x,y);
if x+y<9 then  if i>1 then begin write(suma);suma:=x+y;end else
suma:=x+y
else if x+y=9 then begin
                   iled:=1;
                   while x+y=9 do
                                begin
                                read(x,y);
                                if x+y=9 then inc(iled);
                                end;
                   if x+y<9 then begin
                                 write(suma);
                                 for j:=1 to iled do write(9);

                                 suma:=(x+y);
                                 end;
                   if x+y>9 then begin
                                 write(suma+1);
                                 for j:=1 to iled do write(0);

                                 suma:=(x+y)mod 10;
                                 end;
                   n:=n-iled;
                   end
else begin
     write(suma+1);
     suma:=(x+y)mod 10;
     end;
until i=n;
write(suma);
end.