题目链接:https://www.nowcoder.com/acm/contest/82/A
链接:https://www.nowcoder.com/acm/contest/82/A
来源:牛客网
n的约数
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
t次询问,每次给你一个数n,求在[1,n]内约数个数最多的数的约数个数
输入描述:
第一行一个正整数t 之后t行,每行一个正整数n
输出描述:
输出t行,每行一个整数,表示答案
根据唯一分解定理,ans=p1^e1*p2^e2*......pk^ek,pi为素数且p1<p2<...<pk,
/*
* @Author: Samson
* @Date: 2018-03-30 21:23:31
* @Last Modified by: Samson
* @Last Modified time: 2018-04-09 11:12:36
*/
// @URL : https://www.nowcoder.com/acm/contest/82/A
#include<bits/stdc++.h>
#include<algorithm>
#include <string>
#include <cstdlib>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
const int MAXN = 10000+10;
LL n,ans;
int p[] = {0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
void dfs(int pos,LL num,LL cnt,int lim) //cnt是因子数
{
if(pos > 15) return;
if(cnt > ans) ans = cnt;
for(int i = 1; i <= lim; ++i)
{
if(n/p[pos] < num) break;
num *= p[pos];
dfs(pos+1,num,cnt*(i+1),i);
}
}
int main(void)
{
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
cin>>n;
ans = 1;
dfs(1,1,1,15);
cout<<ans<<'\n';
}
return 0;
}