网站建设 有限公司,神奇网站,wordpress最好最全的教程,南昌seo实用技巧题目大意
给出n#xff0c;问小于n的数中#xff0c;因数最多的数 解题思路
要满足因数最多#xff0c;则小的质因数个数要大于等于打的质因数个数
那么直接按这个需求dfs枚举每个质因数的指数 code
#includecstdio
#includecstring
#includeiostre…题目大意
给出n问小于n的数中因数最多的数 解题思路
要满足因数最多则小的质因数个数要大于等于打的质因数个数
那么直接按这个需求dfs枚举每个质因数的指数 code
#includecstdio
#includecstring
#includeiostream
#includealgorithm
#define ll long long
using namespace std;
ll T,x,now,ans;
ll b[]{1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
void dfs(ll x,ll dep,ll nw,ll as,ll las)
{if(as*xans)return;if(xb[dep]){if(asans||asansnwnow)ansas,nownw;return;}ll g1,gg1;while(xb[dep]glas){x/b[dep];gg*b[dep];g;dfs(x,dep1,nw*gg,as*g,g);}return;
}
int main()
{scanf(%lld,T);while(T--){nowans1;scanf(%lld,x);dfs(x,1,1,1,100);printf(%lld %lld\n,now,ans);}return 0;
}