Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
55426 | zhangweiran | 二进制中的1 | C++ | Accepted | 1 MS | 244 KB | 262 | 2024-11-07 07:28:00 |
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { int sum=0,k; cin>>a[i]; while(a[i]!=0) { k=a[i]%2; if(k==1) sum++; a[i]/=2; } cout<<sum<<" "; } return 0; }