Pagini recente » Cod sursa (job #482218) | Cod sursa (job #1635440) | Cod sursa (job #3222436) | Cod sursa (job #2452682) | Cod sursa (job #73312)
Cod sursa(job #73312)
var i,x,m,p,c,s,ok1,ok2:longint; f1,f2:text;
procedure putere(x:longint);
begin
p:=1;
s:=0;
while p*5<=x do
begin
p:=p*5;
s:=s+x div p;
end;
end;
procedure search(li,ls:longint);
begin
m:=(li+ls) div 2;
putere(m);
ok1:=s;
putere(m-1);
ok2:=s;
if (ok1=x)and(ok2<x) then c:=m
else if li<ls then
if ok2>=x then search(li,m-1)
else search(m+1,ls);
end;
begin
assign(f1,'fact.in');
reset(f1);
assign(f2,'fact.out');
rewrite(f2);
read(f1,x);
search(1,maxlongint);
if c=0 then dec(c);
writeln(f2,c);
close(f1);
close(f2);
end.