题意:
求n以内约数个数最多的数,有多个约数相等的就求最小的那一个。
解题思路:
就是说求反素数,其实可以直接打个表。。
代码:
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL inf=1e18+1;
LL ans;
int p[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
LL n;
int now;
void dfs(int dept, int limit, LL tmp, int num)
{
if(tmp>n)return;
if(num>now || (num==now && tmp<ans))
{
now=num;
ans=tmp;
}
for(int i=1; i<=limit; i++)
{
if(n/p[dept]<tmp)break;
tmp*=p[dept];
dfs(dept+1, i, tmp, num*(i+1));
}
return;
}
int main()
{
int t;
cin>>t;
while(t--)
{
now=0;
ans=inf;
cin>>n;
dfs(0, 64, 1, 1);
printf("%lld %d\n", ans, now);
}
}