题目描述
https://www.acwing.com/problem/content/description/803/
C++ 代码
#include<iostream>
#include<cstdio>
using namespace std;
int lowbit(int x)
{
return x & -x;
}
int main()
{
int n;n
scanf("%d",&n);
while(n--)
{
int x,s=0;
scanf("%d",&x);
while(x) x-=lowbit(x),s++;
cout<<s<<' ';
}
return 0;
}