'commit'
This commit is contained in:
21
TangDou/AcWing/BIT/801.cpp
Normal file
21
TangDou/AcWing/BIT/801.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user