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

Could you help me to find the mistake in my program?
Posted by Daewoo 3 Jun 2004 19:42
const
  max=500000;
var
  data:array[0..max]of byte;
  n:longint;
  mid,i:longint;
  p:integer;
  a,b,a1,b1:integer;
begin
  fillchar(data,sizeof(data),0);
  read(n);
  mid:=n div 2;
  if odd(n)
    then p:=1
    else p:=0;
  for i:=1 to mid do
    begin
      read(a,b);
      read(a1,b1);
      data[i]:=10*(a+b)+a1+b1;
    end;
  for i:=1 to p do
    begin
      read(a,b);
      data[mid+p]:=a+b;
      inc(data[mid],data[mid+p]div 10);
      data[mid+p]:=data[mid+p]mod 10;
    end;
  for i:=mid downto 1 do
    begin
      inc(data[i-1],data[i]div 100);
      data[i]:=data[i]mod 100;
    end;
  if data[0]<>0
    then write(data[0]);
  for i:=1 to mid do
    if data[i]=0
      then write('00')
      else write(data[i]);
  if p>0
    then write(data[mid+p]);
end.
Re: Could you help me to find the mistake in my program?
Posted by Diac Paul 4 Jun 2004 14:51
Could it be the limit? you've got 500000 but the program should work for 1000000; I don't know. I've got a limit excedeed. - I used a 1000000 array of integers - ; then I tryed to stack more digits into one integer but it seems that something is not working well.