Pagini recente » Cod sursa (job #2240924) | Cod sursa (job #567818) | Cod sursa (job #1504694) | Cod sursa (job #2850980) | Cod sursa (job #938382)
Cod sursa(job #938382)
var n,m,s,p :longint;
begin
assign(input,'fact.in');
assign(output,'fact.out');
reset(input);
rewrite(output);
readln(p);
n:=p*4;
repeat
m:=5; s:=0;
while m<=n do begin
s:=s+(n div m) ;
m:=m*5;
end;
inc(n);
until (s=p) or (s>p);
if p=0 then write('1')
else if s=p then write(n-1)
else write('-1');
close(input);
close(output);
end.