蒜头君对一个数的因数个数产生了兴趣,他想知
道在1到n的范围内,因数个数最多的数是多
少。如果有多个这样的数,他想知道最小的那
个。
输入格式
第一行一个整数T.表示数据的组数。
接下来T行,每行一个正整数n。
1≤T≤100,1≤n≤1016
输出格式
-共输出T行,每行-一个正整数表示最多因数
个数的数。
样例输入
10
1 00
1 000
样例输出
6
60
840
\
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
int ys[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
LL n, anx, ans;
void dfs(int u, int m, LL cnt, LL x)
{
if (cnt > ans)
{
ans = cnt;
anx = x;
}
else if (cnt == ans && x < anx)
{anx = x;}
if (u == 15)
return;
for (int i = 1; i <= m; i++)
{
x = x * ys[u];
if ( x > n)break;
dfs(u + 1, i, cnt*(i + 1), x);
}
}
int main()
{
int t;
cin >> t;
while (t--)
{
cin >> n;
anx = 0;
ans = 0;
dfs(0, 60, 1, 1);
cout << anx << endl;
}
}