1 solutions

  • 0
    @ 2025-11-27 11:55:04

    C++ :

    #include <iostream>
    using namespace std;
    int main()
    {
        int l, r, a, b, n, cnt = 0;
        cin >> l >> r;
        a = 1;
        while(a<=r)
        {
            b = a;
            while(b<=r)
            {
                n = a+b;
                if(n>=l && n<=r) cnt++;
                b *= 2;
            }
            a *= 2;
        }
    cout << cnt <<endl;
    return 0;
    }
    
    • 1

    Information

    ID
    27
    Time
    5000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By