You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#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;
|
|
} |