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 WA?
Posted by wangchun 21 Jul 2003 15:34
type digit=0..9;
const max=500001;
var sz:array[1..max]of byte;
    n,s:longint;
procedure add(k:longint;m:digit);
var t:longint;
begin
     t:=(n-k+2)div 2;
     if odd(n-k)then
        sz[t]:=sz[t]+m*10
                else
        sz[t]:=sz[t]+m;
end;
procedure main;
var t:longint;
    a,b:digit;
    e:longint;
begin
     fillchar(sz,sizeof(sz),0);
     readln(n);
     for t:=1 to n do
         begin
              readln(a,b);
              add(t,a+b);
         end;
     for t:=1 to (n+1)div 2 do
         while sz[t]>=100 do
               begin
                    dec(sz[t],100);
                    inc(sz[t+1]);
               end;
     s:=(n+1)div 2+1;
     while (sz[s]=0)and(s>0) do
           dec(s);
     for t:=s downto 1 do
         begin
              a:=sz[t]div 10;
              b:=sz[t]mod 10;
              if a<>0 then
                 write(a)
                      else
                 if t<>s then
                    write(a);
              write(b);
         end;
     if s=0 then
        write(0);
end;
begin
     main;
end.