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 1189. Pairs of Integers

Help! Eager!
Posted by Nickolas Kakà 24 Jun 2008 21:42
'Crash (access violation)| 17| 0.015 |182 KB ',WHAT IS IT?
I just can't understand!
Read FAQ
Posted by Vladimir Yakovlev (USU) 25 Jun 2008 14:08
Re: Help! Eager!
Posted by Nickolas Kakà 26 Jun 2008 20:01
Could anybody give out a test that let this program go wrong?

Code:
type ac=^acm;
acm=record
 v1:longint;
 v2:longint;
 left,right:ac;
end;
var a,c:ac;
b,d,e,f,g,h,i,j,k,l,m,n,s,p,r:longint;
function mln(a:longint):extended;
begin
 if a=0 then exit(a) else exit(ln(a));
end;
procedure goal3(m,l,n:longint);
var i,j,b,p:longint;
procedure goal1(var a:ac);
begin
 if a=nil then begin
  new(a);
  a^.left:=nil;
  a^.right:=nil;
  a^.v1:=b;
  a^.v2:=p;
  inc(s);
 end
 else if b=a^.v1 then

 else if b<a^.v1 then
  goal1(a^.left)
 else
  goal1(a^.right);
end;
begin
 j:=m div 11;
 i:=m-j;
 if i div 10=j then begin
  b:=i*l+n div 2;
  p:=j*l+n div 2;
  if trunc(mln(b)/mln(10))+1>trunc(mln(p)/mln(10))+1 then
   goal1(a);
 end;
 if (m div 10>0)and not odd(m mod 10) then goal3(m div 10,l*10,(m mod 10)*l+n);
 if (m div 10>1)and not odd(m mod 10) then goal3(m div 10-1,l*10,(m mod 10+10)*l+n);
end;
procedure goal2(a:ac);
var i:longint;
begin
 if a^.left<>nil then goal2(a^.left);
 if a<>nil then begin
  write(a^.v1,' + ');
  for i:=trunc(mln(a^.v2)/mln(10))+2 to trunc(mln(a^.v1)/mln(10)) do
   write('0');
  writeln(a^.v2,' = ',k);
 end;
 if a^.right<>nil then goal2(a^.right);
end;
begin
 read(m);
 k:=m;
 s:=0;
 a:=nil;
 goal3(m,1,0);
 writeln(s);
 goal2(a);
end.