1 条题解

  • 1
    @ 2025-12-7 1:02:07
    using namespace std;
    
    bool chk(int n){
        for(int x=0;pow(2,x)<=n;x++){
            for(int y=0;pow(2,y)<=n;y++){
                if(n == pow(2,x) + pow(2,y)){
                    return true;
                }
            }
        }
        return false;
    }
    
    
    int main(){
        int l,r,cnt=0;
        cin >> l >> r;
        for(int i=l;i<=r;i++){
            if(chk(i)==true) cnt++;
        }
        cout << cnt;
        return 0;
    }
    
    

    幂和数(洛谷 B4357)(区间循环+幂和数判断、简单枚举算法)

    信息

    ID
    614
    时间
    1000ms
    内存
    256MiB
    难度
    9
    标签
    (无)
    递交数
    152
    已通过
    11
    上传者