21 lines
308 B
C++
21 lines
308 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
int lowbit(int x) {
|
|
return x & (-x);
|
|
}
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
while (n--) {
|
|
int x;
|
|
cin >> x;
|
|
|
|
int res = 0;
|
|
while (x) x -= lowbit(x), res++;
|
|
|
|
printf("%d ", res);
|
|
}
|
|
return 0;
|
|
} |