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 don't think my program is WRONG,who can tell me?
Posted by lyj_george 10 Aug 2002 08:22
THE RESULT IS WRONG ANSWER INSTEAD OF MEMORY LIMIT EXCEED
SEE THIS:
var
  a , b : array [1..1000002] of byte;
  i , n : longint;
procedure jia;
var
  p : integer;
begin
  for p := 1 to n do begin
    b[p] := a[p] + b[p];
  end;
  for p := 1 to n+2 do begin
    b[p+1] := b[p+1] + b[p] div 10;
    b[p] := b[p] mod 10;
  end;
end;
procedure out;
var
  ws : longint;
begin
  ws := n+5;
  if ws > 1000001 then ws := 1000001;
  while (b[ws]=0) and (ws<>1) do dec(ws);
  for i := ws downto 1 do
    write(b[i]);
  writeln;
end;

begin
  readln(n);
  for i := 1 to n do
    readln(a[n-i+1],b[n-i+1]);
  jia;
  out;
end.

Re: I don't think my program is WRONG,who can tell me?
Posted by Semyon Dyatlov (NSU) 12 Aug 2002 09:13
> THE RESULT IS WRONG ANSWER INSTEAD OF MEMORY LIMIT EXCEED
> SEE THIS:
> var
>   a , b : array [1..1000002] of byte;
>   i , n : longint;
> procedure jia;
> var
>   p : integer;
> begin
>   for p := 1 to n do begin
>     b[p] := a[p] + b[p];
>   end;
>   for p := 1 to n+2 do begin
>     b[p+1] := b[p+1] + b[p] div 10;
>     b[p] := b[p] mod 10;
>   end;
> end;
> procedure out;
> var
>   ws : longint;
> begin
>   ws := n+5;
>   if ws > 1000001 then ws := 1000001;
>   while (b[ws]=0) and (ws<>1) do dec(ws);
>   for i := ws downto 1 do
>     write(b[i]);
>   writeln;
> end;
>
> begin
>   readln(n);
>   for i := 1 to n do
>     readln(a[n-i+1],b[n-i+1]);
>   jia;
>   out;
> end.
>
>
>

I think:
1) you should submit an online solution. I really don't know why it
doesn't get an ML.
2) this solution is wrong. Read the problem text:
Output file should contain EXACTLY N DIGITS in a single line
representing the sum of these two integers,
and then run the following:
4
0 0
0 0
0 0
0 0
The answer must be 0000, but you output 0.