求1~2^64 区间里, 有多少合法数X
合法数: X= a^b ,至少存在2个不同的a
#include <iostream> #include <algorithm> #include <vector> using namespace std; const int N =65536+3; int b[int(1e6)]; __int128_t MAX =1; void init(){ int i,j; b[0]=b[1]=1; for(i=0;i<64;i++) MAX<<=1; MAX-=1; for(i=2;i<65536;i++) if(b[i]==0){ for(j=i*2;j<65536;j+=i) b[j]=1; } } void sov(){ vector<__int128_t> v; v.push_back(1); for(int i=1;i<65536;i++){ __int128_t t = i; __int128_t tmp =t*t*t*t; for(int j = 4;j <= 64;j ++){ if(tmp > MAX)break; if(b[j]){ v.push_back(tmp); } tmp *= t; } } sort(v.begin(),v.end()); int m =unique(v.begin(),v.end())-v.begin(); for(int i=0;i<m;i ++) printf("%llu\n",(unsigned long long)v[i]); } signed main(){ init(); sov(); }
标签:tmp,begin,11752,int,Powers,back,UVA,include,Super From: https://www.cnblogs.com/towboa/p/17327386.html