Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. //*******************************************************************
  2. // Welcome to CompileJava!
  3. // If you experience any issues, please contact us ('More Info') -->
  4. // Sorry that the "Paste" feature no longer works! GitHub broke it.
  5. //*******************************************************************
  6.  
  7. import java.lang.Math; // headers MUST be above the first class
  8. import java.util.*;
  9.  
  10. // one class needs to have a main() method
  11. public class Main
  12. {
  13. public static void main(String[] args)
  14. {
  15. Scanner sc = new Scanner(System.in);
  16. int case = 1;
  17. while(sc.hasNextInt()) {
  18. int m = sc.nextInt();
  19. BigInteger a = new BigInteger("2");
  20. BigInteger curA = a.pow(m).subtract(new BigInteger("1"));
  21. int lo = 0;
  22. int hi = m;
  23. int ans = 0;
  24. while(lo <= hi) {
  25. int mid = lo + (hi - lo) / 2;
  26. if(ok(mid)) {
  27. ans = mid;
  28. low = mid + 1;
  29. }
  30. else hi = mid - 1;
  31. }
  32. System.out.println("Case #" + case + " " + ans);
  33. case++;
  34. }
  35. static boolean ok(int k, BigInteger cc) {
  36. BigInteger b = new BigInteger("10");
  37. BigInteger res = b.pow(k);
  38. int ans = res.compareTo(cc);
  39. if(ans == -1) {
  40. return true;
  41. }
  42. return false;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement