zoj 2562 More Divisors

zoj 2562 More Divisors,第1张

zoj 2562 More Divisors
#include <iostream>#include<cstdio>#include<cstring>#define LL long longusing namespace std;LL m,n,p,q,i,j,k,l,r,ansfin,ansval,nowfin,nowval,cnt;LL prime[105];LL val[105];bool hash[105];void init(){LL i_i,i_j;memset(hash,0,sizeof(hash));memset(prime,0,sizeof(prime));hash[0]=hash[1]=false;cnt=0;for (i_i=2;i_i<=100;i_i++)if (!hash[i_i]){prime[cnt++]=i_i;for (i_j=2;i_j*i_i<=100;i_j++)hash[i_i*i_j]=true;}}void dfs(LL xi){LL d_tem=1,d_i=1;if (nowfin>ansfin || (nowfin==ansfin && nowval<ansval))ansfin=nowfin,ansval=nowval;for (d_i=1;;d_i++){d_tem*=prime[xi];if (nowval*d_tem<=n){nowval*=d_tem;nowfin*=(d_i+1);dfs(xi+1);nowfin/=(d_i+1);nowval/=d_tem;}elsebreak;}}int main() {init();while (scanf("%lld",&n)!=EOF){ansfin=ansval=-1;memset(val,0,sizeof(val));nowval=nowfin=1;dfs(0);printf("%lldn",ansval);}return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4882711.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-11
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存