为什么要用set去重呢,质因子的乘积应该都是唯一的吧,唯一分解定理证明就可以啊,只不过是逆定理。
#include<bits/stdc++.h>
using namespace std;
int n,idx=0;
double b[5000010];
signed main()
{
cin>>n;
if(n==0)
{
cout<<0;
return 0;
}
for(int x1=0;x1<=70;x1++)
{
for(int x2=0;x2<=50;x2++)
{
for(int x3=0;x3<=30;x3++)
{
for(int x4=0;x4<=30;x4++)
{
double ans=pow(2,x1)*pow(3,x2)*pow(5,x3)*pow(7,x4);
if(ans>1e19)
break;
b[++idx]=ans;
}
}
}
}
sort(b+1,b+1+idx);
cout<<(long long)b[n];
return 0;
}