zoukankan      html  css  js  c++  java
  • 容斥 HDU 2204

    #include<stdio.h>
    #include<vector>
    #include<math.h>
    #include<stdlib.h>
    
    using namespace std;
    
    vector<int>s;
    int z[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67};
    typedef __int64 LL;
    
    void Init()
    {
        for(int i=0;z[i]<64;i++) //这个容斥的版挺好的
        {
            for(int j=s.size()-1;j>=0;j--)
                if(abs(s[j]*z[i])<=63)
                    s.push_back(-s[j]*z[i]);//奇加偶减
            s.push_back(z[i]);
        }
    }
    
    int main()
    {
        Init();
        LL x;
        while(scanf("%I64d",&x)!=EOF)
        {
            LL ans=0;
            for(int i=0;i<s.size();i++)
            {
                LL tmp=pow(x+0.5,1.0/abs(s[i]));
                if(s[i]<0)
                    ans-=tmp;
                else
                    ans+=tmp;
            }
            printf("%I64d
    ",ans-1);
        }
        return 0;
    }
  • 相关阅读:
    person
    汽车.
    矩形
    设计模式
    汽车
    三角形
    银行
    西游记
    面向对象
    随机生成4位验证码,输入验证码与生成的比较,最多输入5次
  • 原文地址:https://www.cnblogs.com/cherryMJY/p/6289421.html
Copyright © 2011-2022 走看看