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

Filippov Nickolas SSAU#2's AC program is HERE!
Posted by Nickolas 14 Feb 2003 20:29
program productofdigits;
 var a:array[2..9] of word;
     n:longint;
     i,k:word;
    begin
    Readln(n);
    for i:=2 to 9 do a[i]:=0;
    if n=0 then write(10) else
     if n=1 then write(1) else begin
        for i:=9 downto 2 do
          while n mod i = 0 do begin n:=n div i; inc(a[i]); end;
      if n<>1 then write(-1) else
          for i:=2 to 9 do
              for k:=1 to a[i] do
          write(i);
    end;
    end.