Pagini recente » Cod sursa (job #1496292) | Cod sursa (job #1142339) | Cod sursa (job #367692) | Cod sursa (job #810248) | Cod sursa (job #195620)
Cod sursa(job #195620)
var f,g:text;
a,b,c,t,p:longint;
function zero(c:longint):longint;
var p:longint;
begin
zero:=1;
p:=5;
while p<c do begin
inc(zero,c div p);
p:=p*5;
end;
end;
begin
assign(f,'fact.in');reset(f);
assign(g,'fact.out');rewrite(g);
read(f,p);
a:=1;
b:=100000000;
t:=0;
while (a<=b) do begin
c:=(a+b) div 2;
if zero(c)<p then a:=c+1;
if zero(c)>p then b:=c-1;
if zero(c)=p then begin
writeln(g,c);
inc(t);
break;
end;
end;
if t=0 then writeln(g,'-1');
close(f);
close(g);
end.