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

WA hlp
Posted by Sni 5 Dec 2005 10:13
var n:longint;
    s,ss:string;
    i:integer;
begin
readln(n);s:='';
i:=9;
if n=1 then write('1') else
if n=0 then write('10') else begin
while i>1 do begin
if n mod i=0 then begin str(i,ss);s:=s+ss;n:=n div i;end
else dec(i);
end;

if ss='' then write('-1')
else for i:=length(s) downto 1 do write(s[i]);

end;
end.

Easy program IMHO but WA at test10-Why?
Re: WA hlp
Posted by BSN 6 Dec 2005 10:12
How about example with n=22? Your program will write 2, but 22 is not a 2! :) You must check n in the end of loop for equal 1. Your program can't work if n include prime devisor more than 7. It's easy. My problem was test 4 ;)