Pagini recente » Cod sursa (job #2934369) | Cod sursa (job #1216462) | Cod sursa (job #734542) | Cod sursa (job #1444427) | Cod sursa (job #298784)
Cod sursa(job #298784)
var p,a,b,c:longint;
ok:boolean;
function zero( x:longint ):longint;
var i:longint;
begin
i:=5; zero:=0;
while i<=x do
begin
zero :=zero+x div i;
i:=i*5;
end;
end;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
readln(p);
b:=2000000000;
while not ok do
begin
c:=(a+b) div 2;
if zero(c)=p then ok:=true
else
if zero(c)<p then a:=c+1
else b:=c-1;
if a=b then begin c:=-1; ok := true; end;
end;
if p=0 then writeln(1) else if c<>-1 then writeln(c-c mod 5) else writeln(c);
close(input); close(output);
end.