The Super Powers UVA - 11752
其中k是合数
只有k是合数
参考代码
bool heshu[101];
void init(void)
{
for(int i = 2; i <= 100; ++i)
{
if(!heshu[i])
{
for(int j = i+i; j <= 100; j += i)
heshu[j] = true;
}
}
}//打合数表
const int Max = 65536;
int main(void)
{
std::ios::sync_with_stdio(false);
init();
set<ULL> se;
se.insert(1);//插入1
for(int i = 2; i < 65540; ++i)
{
int sign = floor(64*log(2)/log(i));
ULL cur = i;
for(int j = 2; j <= 64&&j <= sign; ++j)
{
cur *= i;
if(heshu[j])
se.insert(cur);
}
}
se.erase(0);
for(auto c: se)
{
cout<<c<<endl;
}
return 0;
}
第一次总结
1 数学题就是要用数学的方法来做,先想数学方法,后想code