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 on test 2? I don't know why?Help.
Posted by rhctyydjtc 4 Jul 2005 08:52
program ural1048;
const
  maxn=1000000;
  inpath='';
  outpath='';
var
  a:array [0..maxn div 4] of integer;
  n:longint;
  i,j:longint;
  x,y:longint;
begin
  assign(input,inpath);
  reset(input);
  assign(output,outpath);
  rewrite(output);
  readln(n);
  for i:=1 to n mod 4 do
  begin
     read(x,y);
     a[0]:=a[0]*10+x+y;
  end;
  for i:=1 to n div 4 do
  begin
     for j:=1 to 4 do
     begin
        read(x,y);
        a[i]:=a[i]*10+x+y;
     end;
  end;
  for i:=n div 4 downto 1 do
  begin
     a[i-1]:=a[i-1]+a[i] div 10000;
     a[i]:=a[i] mod 10000;
  end;
  i:=0;
  while (a[i]=0) and (i<n div 4) do inc(i);
  write(a[i]);
  inc(i);
  for j:=i to n div 4 do
  begin
     if a[j]>=1000 then write(a[j])
    else if a[j]>=100 then write(0,a[j])
    else if a[j]>=10 then write('00',a[j])
    else write('000',a[j]);
  end;
  writeln;
  close(input);
  close(output);
end.