题解:
数论+报搜
首先套一个计算因子个数的公式
枚举一下这个数
代码:
#include<bits/stdc++.h> using namespace std; int n,ans[100005],res[21],tmp[21]; int pri[]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; double mn=DBL_MAX,lg[21]; void dfs(double x,int y,int z) { if (x>=mn)return; if (y==1) { mn=x; memset(res,0,sizeof(res)); for(int i=1;i<=z-1;i++)res[i]=tmp[i]; return; } if (z>16)return; for (int i=0;(i+1)*(i+1)<=y;i++) if (y%(i+1)==0) { if (i!=0) { tmp[z]=i; dfs(x+lg[z]*i,y/(i+1),z+1); } if ((i+1)*(i+1)!=y) { tmp[z]=y/(i+1)-1; dfs(x+lg[z]*(y/(i+1)-1),i+1,z+1); } } } int main() { scanf("%d",&n); for (int i=1;i<=16;i++)lg[i]=log(pri[i]); dfs(0,n,1); ans[0]=ans[1]=1; for (int i=1;i<=16;i++) for (;res[i]>0;res[i]--) { for (int j=1;j<=ans[0];j++)ans[j]*=pri[i]; for (int j=1;j<=ans[0];j++)ans[j+1]+=ans[j]/10,ans[j]%=10; if (ans[ans[0]+1]!=0) ans[0]++; while (ans[ans[0]]/10!=0) ans[ans[0]+1]+=ans[ans[0]]/10,ans[ans[0]]%=10,++ans[0]; } for (int i=ans[0];i>=1;i--)printf("%d",ans[i]); return 0; }