题目:
题意:
一个数的得分为可以整除自己的数的个数,问在 1 ∼ n 1\sim n 1∼n中,得分最大的数是哪个,并输出得分
分析:
e
m
m
emm
emm反素数
?
?
?
为了表示是新题还开大范围和多组数据
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<ctime>
#define LL long long
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
LL n,ans,king,s[19],p[19]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61};
void dfs(LL x,LL sum,LL mul)
{
if(x>18) return;
if(sum>ans||sum==ans&&mul<king)
{
ans=sum;
king=mul;
}
s[x]=0;
while(p[x]<=n/mul&&s[x]<=s[x-1])
{
s[x]++;
LL kkk=sum*(s[x]+1);
mul*=p[x];
dfs(x+1,kkk,mul);
}
return;
}
int main()
{
// freopen("1.txt","r",stdin);
// freopen("1.out","w",stdout);
s[0]=1e19;
int t=read();
while(t--)
{
n=read();
king=0;ans=0;
dfs(1,1,1);
printf("%lld %lld\n",king,ans);
}
return 0;
}