Pagini recente » Cod sursa (job #331855) | Cod sursa (job #1708305) | Cod sursa (job #2562468) | Cod sursa (job #2987595) | Cod sursa (job #1075621)
program fact;
var p,n,i,j,m:qword;
gasit:boolean;
function nrz(n:qword):qword;
var k,i:qword;
begin
i:=5; k:=0;
while n div i<>0 do
begin
inc(k,n div i);
i:=i*5;
end;
nrz:=k;
end;
begin
assign(input,'fact.in');
reset(input);
assign(output,'fact.out');
rewrite(output);
readln(p);
i:=1;
j:=1000000000;
gasit:=false;
while (i<=j) and not gasit do
begin
n:=(i+j) div 2+1;
if nrz(n)=p then gasit:=true
else if nrz(n)>p then j:=n-1
else i:=n+1;
end;
if gasit then begin
while n mod 5<>0 do dec(n);
writeln(n)
end
else
writeln(-1);
close(output);
end.