fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.Scanner;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int n, m;
  13. double k;
  14. Scanner scan = new Scanner(System.in);
  15. n = scan.nextInt();
  16. m = (int)(Math.log(n)/Math.log(2));
  17. k = (double)(Math.log(n)/Math.log(2));
  18. while (m != k){
  19. n = (int)(n - (Math.pow(2,m)));
  20. m = (int)(Math.log(n)/Math.log(2));
  21. k = (double)(Math.log(n)/Math.log(2));
  22. }
  23. System.out.print(m + 1);
  24. }
  25. }
Success #stdin #stdout 0.06s 2184192KB
stdin
158
stdout
2