1 solutions

  • 0
    @ 2026-11-15 12:45:04

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    long long lowbit(long long x) {
        return x & -x;
    }
    
    int main() {
        long long n, cnt = 0;
        cin >> n;
        for (long long i = n; i > 0; i -= lowbit(i)) cnt++;
        cout << cnt << endl;
        return 0;
    }
    
    • 1

    Information

    ID
    193
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    1
    Uploaded By