公司动态

The Super Powers UVA - 11752n

📅 2026/7/28 14:39:56
The Super Powers UVA - 11752n
要注意数据范围longlong是有符号长整形要想让范围是264−1必须用无符号长整形unsinged long long底数最小为2此时指数正如题目所给最大为64指数最小为4最小的合数此时我们可以算出底数最大为216 ( (216)4264 )直接枚举#includeiostream #includecstdio #includecstring #includeset using namespace std; #define ll unsigned long long const int maxn645; ll inf(164)-1; bool isprime[maxn]; void is() { //p[0]p[1]1; 1不是和数 for(int i2;imaxn;i) { if(!isprime[i]) { for(int ji;i*jmaxn;j) isprime[i*j]1; } } } setll s; int main() { is(); for(int i2;i65536;i) { ll ans1; for(int j1;j64;j) { ans*i; if(isprime[j]) s.insert(ans); if(ansinf/i) break; if(ans*iinf) break;//这样写会溢出 } } s.insert(1); setll::iterator it; for(its.begin();it!s.end();it) { cout*itendl; } return 0; }