题解:
数论+报搜
首先套一个计算因子个数的公式
枚举一下这个数
代码:
#include<bits/stdc++.h>
using namespace std;
int n,ans[],res[],tmp[];
int pri[]={,,,,,,,,,,,,,,,,};
double mn=DBL_MAX,lg[];
void dfs(double x,int y,int z)
{
if (x>=mn)return;
if (y==)
{
mn=x;
memset(res,,sizeof(res));
for(int i=;i<=z-;i++)res[i]=tmp[i];
return;
}
if (z>)return;
for (int i=;(i+)*(i+)<=y;i++)
if (y%(i+)==)
{
if (i!=)
{
tmp[z]=i;
dfs(x+lg[z]*i,y/(i+),z+);
}
if ((i+)*(i+)!=y)
{
tmp[z]=y/(i+)-;
dfs(x+lg[z]*(y/(i+)-),i+,z+);
}
}
}
int main()
{
scanf("%d",&n);
for (int i=;i<=;i++)lg[i]=log(pri[i]);
dfs(,n,);
ans[]=ans[]=;
for (int i=;i<=;i++)
for (;res[i]>;res[i]--)
{
for (int j=;j<=ans[];j++)ans[j]*=pri[i];
for (int j=;j<=ans[];j++)ans[j+]+=ans[j]/,ans[j]%=;
if (ans[ans[]+]!=) ans[]++;
while (ans[ans[]]/!=)
ans[ans[]+]+=ans[ans[]]/,ans[ans[]]%=,++ans[];
}
for (int i=ans[];i>=;i--)printf("%d",ans[i]);
return ;
}