#include<iostream> using namespace std; const int N=1e5+10; int q[N]; int low(int x){ return x&(-x); } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ scanf("%d",&q[i]); } for(int i=0;i<n;i++){ int res=0; while(q[i]) { q[i]-=low(q[i]); res++; } cout<<res<<" "; } }
标签:std,二进制,个数,int,801,Acwing From: https://www.cnblogs.com/ljq20204136/p/16840022.html