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

OSPU I have AC [3] // Problem 1048. Superlong Sums 15 Mar 2003 13:04
program a1048;
const nn=500003;
var a:array[0..nn] of byte;
i,j,c,b,n:longint;

procedure mass(i:longint;x:byte);
begin
if i mod 2=0 then a[i div 2]:=(a[i div 2] mod 10)+x*10
else a[i div 2]:=(a[i div 2] div 10)*10+x;
end;

function mas(i:longint):byte;
begin
if i mod 2 =0 then mas:=a[i div 2] div 10
else mas:=a[i div 2] mod 10;
end;

begin
fillchar(a,SizeOf(a),0);
readln(n);
for i:=1 to n do
   begin
   readln(b,c);
   b:=b+c;
   for j:=i downto 1do
      begin
      b:=b+mas(j);
      mass(j,b mod 10);
      b:=b div 10;
      if b=0 then break;
      end;
   end;
for i:=1 to n do
   write(mas(i));
writeln;
end.
SunMoonStar Re: I have AC // Problem 1048. Superlong Sums 16 Mar 2003 19:34
What a long, slow, big program!