fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. int32_t main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9.  
  10. int x;
  11. cin >> x;
  12.  
  13. int rs = 0;
  14. while(x) {
  15. if((x&1) != 0) rs++;
  16. x/=2;
  17. }
  18.  
  19. cout << rs << endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
15