fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.Scanner;
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. int k=0, n;
  11. Scanner in = new Scanner(System.in);
  12. n = in.nextInt();
  13. while (n > 0){
  14. k += (n % 2);
  15. n = n / 2;
  16. }
  17. System.out.print(k);
  18. }
  19. }
Success #stdin #stdout 0.06s 2184192KB
stdin
5
stdout
2