while True: try: n=int(input()) count=0 s=bin(n) for i in range(2,len(s)): if s[i]=='1': count+=1 print(count) except: break
#include <iostream> #include <bitset> using namespace std; int main(){ int n; while(cin >> n){ bitset<32> bs(n); cout << bs.count() << endl; } return 0; }
#include <iostream> using namespace std; int main(){ int n; while(cin >> n){ int count=0; while(n){ if(n%2==1){ count++; } n/=2; } cout << count << endl; } return 0; }