You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
329 B

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
//手工版本数字1个数
int count1(int x) {
int cnt = 0;
while (x) {
cnt++;
x -= (x & -x);
}
return cnt;
}
int main() {
cout << count1(2147483647) << endl;
return 0;
}