牛客-二进制中1的个数
#include <stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <string.h>
#include <string>
#include <cstring>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
class Solution {
public:
int NumberOf1(int n) {
int ans=0;
while (n!=0) {
ans++;
n=(n-1)&n;
}
return ans;
}
};