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 1014. Product of Digits

What's wrong with my program
Posted by gaozhenwei 3 Apr 2002 16:24
var s:array[1..30] of byte;
    n,i,t:longint;
begin
 read(n);i:=9;t:=31;
 if n=0 then
  begin writeln('10');halt;end
  else if n=1 then begin writeln('1');halt;end;
 while i<>1 do
 begin
  while n mod i=0 do
  begin
   dec(t);
   s[t]:=i;
   n:=n div i;
  end;
  dec(i);
 end;
 if n=1 then
 begin
  for i:=t to 30 do write(s[i]);
  writeln;
 end
  else writeln('?');
end.
Re: What's wrong with my program
Posted by Ivan Georgiev 3 Apr 2002 21:17
I think you should output '-1' instead of '?' if the test has no
solution.

Good luck.
Re: What's wrong with my program
Posted by gaozhenwei 4 Apr 2002 15:56
Thank you very much.