Pagini recente » Cod sursa (job #1692502) | Cod sursa (job #2956047) | Cod sursa (job #2430277) | Cod sursa (job #2477356) | Cod sursa (job #195631)
Cod sursa(job #195631)
var f,g:text;
a,b,c,t,p:longint;
function zero(c:longint):longint;
var p:longint;
begin
zero:=0;
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);
if p<>0 then begin
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-c mod 5);
inc(t);
break;
end;
end;
if t=0 then writeln(g,'-1');
end;
if p=0 then writeln(g,'1');
close(f);
close(g);
end.