Description
XueXX is a clever boy. And he always likes numbers in binary(二进制). What an interesting hobby!
Now XueXX has some number in decimal(十进制), he wants to know how many “1”s in a number if the number is written in binary.
Input
The first line of input contains the number of test cases T (T<=100). The descriptions of the test cases follow: The first line of each test case contains one integer a (0
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,ans=0;
cin>>n;
while(n)
{
n&=n-1;
ans++;
}
cout<<ans<<endl;
}
return 0;
}