定理:一個數約數個數=所有素因子的次數+1的乘積
然後得一個2000000000以內的數字不會有超過12個素因子
在一個因子數爲n的集合中,這個集合中最小的數就是一個反質數。
所以我們只要找出小於n的數中因數個數最多的最小數。
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const LL Inf = (unsigned)(-1) >> 1;
int prm[10]={2,3,5,7,11,13,17,19,23,29};
int num;
LL Ans,n;
void Dfs(int x,int y,LL z){
if(y > num) num = y,Ans = Inf;
if(y == num) Ans = min(Ans,z);
if(x >= 10) return;
for(int i=0;z<=n;z*=prm[x],i++) Dfs(x+1,y*(i+1),z);
}
int main(){
scanf("%lld",&n);Dfs(0,1,1);printf("%lld",Ans);return 0;
}