Pagini recente » Cod sursa (job #1615501) | Cod sursa (job #842109) | Cod sursa (job #1411973) | Cod sursa (job #3188324) | Cod sursa (job #353833)
Cod sursa(job #353833)
program factorial;
var ok:byte;
f,g:text;
min,i,e,p,x,y:longint;
begin
assign(f,'fact.in');
reset(f);
assign(g,'fact.out');
rewrite(g);
read(f,p);
i:=0; x:=0; y:=0;
min:=0;
while(min<p) do
begin
e:=e+1; i:=e;
ok:=0;
if (i mod 4=2) then begin x:=x+1; ok:=1; end;
if ((i-4) mod 8=0) then begin x:=x+2; ok:=1; end;
if ((i-8) mod 16=0) then begin x:=x+3; ok:=1; end;
if ok=0 then
while(i mod 2=0) do
begin
x:=x+1;
i:=i div 2;
end;
ok:=0;
if (i mod 5=0) and (i mod 25<>0) then begin ok:=1; y:=y+1; end;
if ok=0 then
while(i mod 5=0) do
begin
y:=y+1;
i:=i div 5;
end;
if x<y then min:=x else min:=y;
if x=y then min:=x;
if min>=p then break;
end;
if e=0 then e:=1;
if e<0 then e:=-1;
write(g,e);
close(f);
close(g);
end.