a&1 为当前为当前a末位是否为1
#include<iostream>
const int N = 1e6+10;
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int res = 0,num;
scanf("%d",&num);
while(num>0)
{
res+= num&1;
num=num>>1;
}
printf("%d ",res);
}
}
不愧是大佬