题目描述
blablabla
样例
blablabla
C++ 代码
#include<iostream>
using namespace std;
int n;
const int N = 100010;
int a[N];
int lowbit(int n)
{
return n& -n;
}
int main()
{
cin >> n;
/* for(int i =0; i < n; i++)
{ cin >> a[i];
int sum = 0;
while(a[i])
{
if(a[i] & 1)
sum++;
a[i] >>= 1;
}
cout << sum <<" ";
}*/ //按位和lowbit
for(int i =0; i < n; i++)
{ cin >> a[i];
int sum = 0;
while(a[i])
{
sum++;
a[i] -= lowbit(a[i]);
}
cout << sum <<" ";
}
return 0;
}