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 1153. Supercomputer

What is test#7?
Posted by nickolas stoudemire 22 Aug 2007 20:36
I got Crash (stack overflow) when my solution met it.
Re: What is test#7?
Posted by nickolas stoudemire 22 Aug 2007 20:52
type ac=array[1..601]of longint;
var a,c,mi,lan,ch:ac;
b,d,e,f,g,h,i,j,k,l,m,n:longint;t:array[1..601]of char;
function times(a,c:ac;n:longint):ac;
var i,j,l:longint;
begin
 fillchar(ch,sizeof(ch),0);
 for i:=n downto 1 do begin
  l:=0;
  for j:=n downto 1 do
   if i+j-n>0 then begin
    ch[i+j-n]:=ch[i+j-n]+a[i]*c[j]+l;
    l:=ch[i+j-n] div 10;
    ch[i+j-n]:=ch[i+j-n] mod 10;
   end;
 end;
 times:=ch;
end;
function larger(a,c:ac;n:longint):boolean;
var i:longint;
begin
 for i:=1to n do
  if a[i]>c[i] then exit(true)
  else if a[i]<c[i] then exit(false);
 exit(false);
end;
procedure goal(g:longint);
var i,j:longint;
begin
 if g=602 then begin
  for i:=601-m+1 to 601 do
   write(c[i]);
  WRITELN;
  halt;
 end;
 fillchar(lan,sizeof(lan),0);
 if odd(n) then
  for j:=2to (g-(601-m))*2 do
   LAN[j]:=a[j+(601-n)-1]
 else
  for j:=1to (g-(601-m))*2 do
   LAN[j]:=a[j+(601-n)];
 for i:=1to 10 do begin
  if i<10 then begin
   c[g]:=i;
   fillchar(mi,sizeof(mi),0);
   for j:=1to g-(601-m) do
    mi[j+g-(601-m)]:=c[j+(601-m)];
   mi:=times(mi,mi,(g-(601-m))*2);
  end;
  if i=10 then begin
   c[g]:=9;
   goal(g+1);
  end
  else if larger(mi,lan,(g-(601-m))*2) then begin
   c[g]:=i-1;
   goal(g+1);
  end;
 end;
end;
begin
 n:=0;
 repeat
  inc(n);
  read(t[n]);
 until eoln;
 for i:=1to n do
  a[601-n+i]:=ord(T[I])-48;
 h:=0;
 for i:=601 downto 1 do begin
  a[i]:=a[i]*2+h;
  h:=a[i] div 10;
  a[i]:=a[i] mod 10;
 end;
 for i:=1to 601 do
  if a[i]<>0 then break;
 n:=602-i;
 m:=(n+1)div 2;
 goal(601-m+1);
end.

I think it's OK.
Does anybody know what's wrong with it?