Pagini recente » Cod sursa (job #1054491) | Profil CobzaruAntonio | Cod sursa (job #163595) | Cod sursa (job #2737518) | Cod sursa (job #525564)
Cod sursa(job #525564)
var p,n:int64;
procedure init;
var f:text;
begin
assign(f, 'fact.in');
reset(f);
readln(f, p);
close(f);
end;
procedure rez;
var f:text;
begin
assign(f, 'fact.out');
rewrite(f);
write(f,n);
close(f);
end;
function nrc(k:int64):int64;
var s,p:int64;
begin
p:=k;
s:=0;
while p> 0
do begin
p:=p div 5;
s:=s+p;
end;
nrc:=s;
end;
procedure calc;
var p1, p2:int64;
begin
if p=0
then n:=1
else
begin
p1:=p; p2:=p;
while p2>5 do
begin
p2:=p2 div 5;
p1:=p1-p2;
end;
n:=p1*5;
while nrc(n)<p do n:=n+5;
if nrc(n)<>p then n:=-1;
end;
end;
begin
init;
calc;
rez;
end.