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

I got 'Output Limit Exceeded'. Why?
Posted by XiaoTian 25 Jan 2003 08:44
{No.1048 Superlong sums.}
Const
     Ch:Array[0..9] Of Char=('0','1','2','3','4','5','6','7','8','9');
Var
     N:LongInt;
     X,Y,Last,NineC:LongInt;
     i,j:LongInt;
Begin
     ReadLn(N);
     ReadLn(X,Y);
     Last:=X+Y;
     For i:=2 To N Do
     Begin
          ReadLn(X,Y);
          If X+Y>=10 Then
          Begin
               Write(Ch[Last+1]);
               For j:=1 To NineC Do
                    Write(Ch[0]);
               Last:=X+Y-10;
               NineC:=0;
          End
          Else If X+Y=9 Then
               Inc(NineC)
          Else Begin
               Write(Ch[Last]);
               For j:=1 To NineC Do
                    Write(Ch[9]);
               Last:=X+Y;
               NineC:=0;
          End;
     End;
     Write(Ch[Last]);
     For i:=1 To NineC Do
          Write(Ch[9]);
     WriteLn;
End.
Beacuse "Writeln
Posted by Lin 25 Jan 2003 16:32
> {No.1048 Superlong sums.}
> Const
>      Ch:Array[0..9] Of Char=
('0','1','2','3','4','5','6','7','8','9');
> Var
>      N:LongInt;
>      X,Y,Last,NineC:LongInt;
>      i,j:LongInt;
> Begin
>      ReadLn(N);
>      ReadLn(X,Y);
>      Last:=X+Y;
>      For i:=2 To N Do
>      Begin
>           ReadLn(X,Y);
>           If X+Y>=10 Then
>           Begin
>                Write(Ch[Last+1]);
>                For j:=1 To NineC Do
>                     Write(Ch[0]);
>                Last:=X+Y-10;
>                NineC:=0;
>           End
>           Else If X+Y=9 Then
>                Inc(NineC)
>           Else Begin
>                Write(Ch[Last]);
>                For j:=1 To NineC Do
>                     Write(Ch[9]);
>                Last:=X+Y;
>                NineC:=0;
>           End;
>      End;
>      Write(Ch[Last]);
>      For i:=1 To NineC Do
>           Write(Ch[9]);
>      WriteLn;
> End.
>
I deleted it, but got the same message.
Posted by XiaoTian 26 Jan 2003 08:14
{No.1048 Superlong sums.}
Const
     Ch:Array[0..9] Of Char=('0','1','2','3','4','5','6','7','8','9');
Var
     N:LongInt;
     X,Y,Last,NineC:LongInt;
     i,j:LongInt;
Begin
     ReadLn(N);
     ReadLn(X,Y);
     Last:=X+Y;
     For i:=2 To N Do
     Begin
          ReadLn(X,Y);
          If X+Y>=10 Then
          Begin
               Write(Ch[Last+1]);
               For j:=1 To NineC Do
                    Write(Ch[0]);
               Last:=X+Y-10;
               NineC:=0;
          End
          Else If X+Y=9 Then
               Inc(NineC)
          Else Begin
               Write(Ch[Last]);
               For j:=1 To NineC Do
                    Write(Ch[9]);
               Last:=X+Y;
               NineC:=0;
          End;
     End;
     Write(Ch[Last]);
     For i:=1 To NineC Do
          Write(Ch[9]);
End.