Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*******************************************************************
- // Welcome to CompileJava!
- // If you experience any issues, please contact us ('More Info') -->
- // Sorry that the "Paste" feature no longer works! GitHub broke it.
- //*******************************************************************
- import java.lang.Math; // headers MUST be above the first class
- import java.util.*;
- // one class needs to have a main() method
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- int case = 1;
- while(sc.hasNextInt()) {
- int m = sc.nextInt();
- BigInteger a = new BigInteger("2");
- BigInteger curA = a.pow(m).subtract(new BigInteger("1"));
- int lo = 0;
- int hi = m;
- int ans = 0;
- while(lo <= hi) {
- int mid = lo + (hi - lo) / 2;
- if(ok(mid)) {
- ans = mid;
- low = mid + 1;
- }
- else hi = mid - 1;
- }
- System.out.println("Case #" + case + " " + ans);
- case++;
- }
- static boolean ok(int k, BigInteger cc) {
- BigInteger b = new BigInteger("10");
- BigInteger res = b.pow(k);
- int ans = res.compareTo(cc);
- if(ans == -1) {
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement