PersonalCorpus 版 (精华区)

149204 14:26:45 1 Mar 2002
Bozhang,HIT,P.R.China 1014 Pascal Accepted 0.02 sec 61K


const sp:array[0..2,0..1] of string=(('','3'),('2','6'),('4','26'));
var
    i,n:integer;
    m2,m3,m5,m7:integer;
    s:string;
begin
    readln(n);
    if n=0 then begin writeln(10);halt end;
    if n=1 then begin writeln(1);halt end;
    m2:=0;    m3:=0;    m5:=0;    m7:=0;
    while n mod 2=0 do begin inc(m2); n:=n div 2 end;
    while n mod 3=0 do begin inc(m3); n:=n div 3 end;
    while n mod 5=0 do begin inc(m5); n:=n div 5 end;
    while n mod 7=0 do begin inc(m7); n:=n div 7 end;
    if n>1 then begin writeln(-1); halt end;
    s:=sp[m2 mod 3 ,m3 mod 2];
    for i:=1 to m2 div 3 do s:=s+'8';
    for i:=1 to m3 div 2 do s:=s+'9';
    i:=1; while (i<=length(s)) and (s[i]<'5') do inc(i);
    for n:=1 to m5 do insert('5',s,i);
    while (i<=length(s)) and (s[i]<'7') do inc(i);
    for n:=1 to m7 do insert('7',s,i);
    writeln(s);
end.
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.886毫秒