fork download
  1.  
  2. #include <iostream>
  3. #include <cmath>
  4. #include <string>
  5. using namespace std;
  6. int main() {
  7. int num,c=0;
  8. cin >> num;
  9. while (num > 0)
  10. {
  11. if (num % 2 != 0)
  12. c++;
  13. num /= 2;
  14. }
  15. cout << c<<endl;
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5308KB
stdin
5
stdout
2