Pagini recente » Cod sursa (job #1102016) | Cod sursa (job #586674) | Cod sursa (job #2728969) | Cod sursa (job #3262476) | Cod sursa (job #199715)
Cod sursa(job #199715)
const nr=1 shl 30;
var p,k,i,rez:longint;
n:qword;
f:text;
{
function nr5(x:longint):longint;
var p,k,i,cn:longint;
begin
i:=5; k:=0;
while i<=x do
begin
p:=0;
cn:=i;
while cn mod 5=0 do begin cn:=cn div 5; inc(p); end;
inc(k,p);
inc(i,5);
end;
nr5:=k;
end;
}
function nr5(x:longint):longint;
var cn,k:longint;
begin
k:=0;
while x>0 do begin inc(k,x div 5); x:=x div 5; end;
nr5:=k;
end;
function cb(x:longint):int64;
var i,step,rez:qword;
begin
step:=nr;
i:=0;
while step>0 do
begin
rez:=nr5(i+step);
if (rez<x) then inc(i,step);
step:=step shr 1;
end;
cb:=i+1;
end;
begin
assign(f,'fact.in');
reset(f);
read(f,p);
close(f);
assign(f,'fact.out');
rewrite(f);
write(f,cb(p));
close(f);
end.