Pagini recente » Cod sursa (job #1505566) | Cod sursa (job #1185658) | Cod sursa (job #715083) | Cod sursa (job #1872597) | Cod sursa (job #359167)
Cod sursa(job #359167)
var p,n,i,x:longint;
function div5(x:longint):byte;
var m:byte;
begin
m:=0;
while x mod 25=0 do begin
inc(m,2);
x:=x div 25;
end;
if x mod 5=0 then inc(m);
div5:=m;
end;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
readln(p);
i:=0;
n:=0;
repeat
x:=1;
inc(i);
n:=n+x*5;
if i mod 5=0 then x:=div5(n);
p:=p-x;
until p<1;
if p<0 then write(-1)
else write(n);
close(input);close(output);
end.