19 lines
329 B
C++
19 lines
329 B
C++
#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;
|
|
} |