题目:
代码:文章来源:https://uudwc.com/A/Pmg9j
#include<iostream>
using namespace std;
const int N=100010;
int a[N];
int n;
int lowbit(int x){
return x & -x;
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=0;i<n;i++){
int res=0;
while(a[i]>0){
a[i] -= lowbit(a[i]);
res++;
}
printf("%d ",res);
}
}
文章来源地址https://uudwc.com/A/Pmg9j