Description
对于任何正整数x,其约数的个数记作g(x)。例如g(1)=1、g(6)=4。
如果某个正整数x满足:g(x)>g(i) 0
Input
一个数N(1<=N<=2,000,000,000)。
Output
不超过N的最大的反质数。
Sample Input
1000
Sample Output
840
HINT
Source
求一个小于n的数x,使
(打表的程序到现在还没跑完…)
这题选小素数肯定比选大素数优,所以枚举小素数选几个暴力即可…
(hzwer说12个素数就可以了…求证明QAQ)
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int SZ = 10000010;
bool vis[SZ];
int pri[] = {0,2,3,5,7,11,13,17,19,23,29,31,37};
int n;
int ans,maxd = 0;
int t[SZ];
void dfs(LL now,int d,int pos)
{
if(d > maxd || (d == maxd && now < ans)) ans = now,maxd = d;
if(pos == 13) return;
LL a = 1;
for(int i = 0;;i ++)
{
if(a * now > n) break;
dfs(now * a,d * (i + 1),pos + 1);
a *= pri[pos];
}
}
int main()
{
scanf("%d",&n);
dfs(1,1,1);
printf("%d",ans);
return 0;
}
/* 1,2,4,6,12,24,36,48,60,120,180,240,360,720,840,1260,1680,2520,5040,7560,10080,15120,20160,25200,27720,45360,50400,55440,83160,110880,166320,221760,277200,332640,498960,554400,665280,720720,1081080,1441440,2162160,2882880,3603600,4324320,6486480,7207200,8648640, 2000000000 */