题解 | 二进制位中1的数量
二进制位中1的数量
https://www.nowcoder.com/practice/3e392d0ed7e543f3a4ae883d1470ca9d
#include <iostream>
using namespace std;
int main(){
long long a;
cin>>a;
int c=0;
while(a){
c+=a&1;
a>>=1;
}
cout<<c<<endl;
return 0;
}
// 64 位输出请用 printf("%lld")