给定一个正整数 \(n\),对于所有不超过 \(n\) 的正整数,找到包含约数最多的一个数。如果有多个这样的数,那么回答最小的那个。
有几个定理。\(G(N)\) 为约数个数,\(pri_i\) 为一些质数。
\[G(N)=\prod k_i+1\]
\[\texttt{满足:} \prod pri_i^{k_i}=N\]
也就是说 \(N\) 的约数个数可以由一系列的质数点指数乘积。然后暴搜索即可。
// T3
Const
total=100000;
border=64;
var
judge,number:array[-1..total] of longint;
ans:array[1..2] of int64;
i:longint;
n:int64;
procedure work;
var i,j:longint; tail:longint;
begin
tail:=0; judge[1]:=1;
for i:=2 to total do
begin
if judge[i]=0 then begin inc(tail); number[tail]:=i; end;
for j:=1 to tail do
begin
if i*number[j]>total then break;
judge[i*number[j]]:=1;
if i mod number[j]=0 then break;
end;
end;
end;
procedure Dfs(x,exponet:longint;sum:int64); // 第几个质数,指数上界,这个质数的指数,到现在的总值
var
i:longint;
tmp:int64;
begin
if (exponet>ans[2])or((exponet=ans[2])and(sum<ans[1])) then begin ans[1]:=sum; ans[2]:=exponet end;
tmp:=1;
for i:=1 to border do
begin
tmp:=tmp*number[x];
if (tmp>n)or(sum*tmp>n) then break;
Dfs(x+1,exponet*(i+1),sum*tmp);
end;
end;
begin
read(n); Work; ans[1]:=maxlongint;
Dfs(1,1,1); writeln(ans[1]);
end.