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 I got WA?
Posted by kupa 1 Jul 2002 17:06
program kupa;
var
tb1:array [1..1000000] of byte;
tb2:array [1..1000000] of byte;
wyn:array [1..1000001] of byte;
x,y,n,z:longint;
p:byte;
begin
readln(n);
for x:=1 to n do
 readln(tb1[x],tb2[x]);
for x:=n downto 1 do
 begin
 if tb1[x]+tb2[x]+p>9 then
  begin
  wyn[x+1]:=tb1[x]+tb2[x]-10+p;
  p:=1;
  end
  else
  begin
  wyn[x+1]:=tb1[x]+tb2[x]+p;
  p:=0;
  end;
 end;
 if p=1 then wyn[1]:=1;
 z:=1;
 while (wyn[z]=0)and(z<n+1)do
 begin
 z:=z+1;
 end;
 begin
 for y:=z to n+1 do
 write(wyn[y]);writeln;
 end;
end.