The Super Powers UVA - 11752

The Super Powers UVA - 11752

ik<264
klog(i)<64log(2)
k<64log(2)/log(i)
其中k是合数
只有k是合数
ik=(ia)b
ab=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

posted on 2017-09-30 23:26  zzuzxy  阅读(109)  评论(0)    收藏  举报

导航