Pagini recente » Cod sursa (job #1776068) | Cod sursa (job #1884914) | Cod sursa (job #1922366) | Cod sursa (job #1046069) | Cod sursa (job #1199184)
var p,n:qword;
i,j:qword;
k,l:qword;
aux:qword;
function ok(k,l:qword):qword;
var p,i:qword;
begin
p:=1;
i:=0;
while (i<l) do begin
p:=p*k;
inc(i);
end;
ok:=p;
end;
begin
assign(input,'fact.in');
reset(input);
readln(p);
close(input);
assign(output,'fact.out');
rewrite(output);
if p=0 then begin
writeln(1);
close(output);
halt(0);
end;
n:=p*4;
k:=0;
while (k<p) do begin
j:=1;
i:=ok(5,j);
aux:=0;
while (n div i<>0) do begin
aux:=aux+(n div i);
inc(j);
i:=ok(5,j);
end;
k:=aux;
inc(n);
end;
if (k=p) then writeln(n-1) else writeln(-1);
close(output);
end.