solution.cpp 276 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
using namespace std;
int main()
{
    int n = 1543, cnt = 0;
    while (n)
    {
        if (n & 1)
        {
            n--;
            cnt++;
            n /= 2;
        }
        else
            n /= 2;
    }
    cout << cnt << endl;
    return 0;
}