Pagini recente » Cod sursa (job #2555745) | Cod sursa (job #2317730) | Cod sursa (job #2811237) | Cod sursa (job #1951631) | Cod sursa (job #199721)
Cod sursa(job #199721)
const nr=1 shl 30;
var p:longint;
f:text;
function nr5(x:longint):longint;
var k:longint;
begin
k:=0;
while x>0 do begin inc(k,x div 5); x:=x div 5; end;
nr5:=k;
end;
procedure cb(x:longint);
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;
if rez=x then write(f,i+1) else write(f,-1);
end;
begin
assign(f,'fact.in');
reset(f);
read(f,p);
close(f);
assign(f,'fact.out');
rewrite(f);
cb(p);
close(f);
end.