/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static int maxGap(int n) { // get rid of right-hand zeros while (n != 0 && (n & 1) == 0) { n >>>= 1; } int max = 0; int gap = 0; while (n != 0) { if ((n & 1) == 0) { gap++; } else { gap = 0; } n >>>= 1; } return max; } public static int maxGapX(int n) { if (n == 0) { return 0; } int max = 0; for (n >>>= (rbits + 1); n != 0; n >>>= (rbits + 1)) { } return max; } return "00000000000000000000000000000000".substring(bin.length()) + bin; } for (int i = 0; i < 100; i++) { } } }
Standard input is empty
Max gap in 0 (00000000000000000000000000000000) is 0 - 0 Max gap in 1 (00000000000000000000000000000001) is 0 - 0 Max gap in 2 (00000000000000000000000000000010) is 0 - 0 Max gap in 3 (00000000000000000000000000000011) is 0 - 0 Max gap in 4 (00000000000000000000000000000100) is 0 - 0 Max gap in 5 (00000000000000000000000000000101) is 1 - 1 Max gap in 6 (00000000000000000000000000000110) is 0 - 0 Max gap in 7 (00000000000000000000000000000111) is 0 - 0 Max gap in 8 (00000000000000000000000000001000) is 0 - 0 Max gap in 9 (00000000000000000000000000001001) is 2 - 2 Max gap in 10 (00000000000000000000000000001010) is 1 - 1 Max gap in 11 (00000000000000000000000000001011) is 1 - 1 Max gap in 12 (00000000000000000000000000001100) is 0 - 0 Max gap in 13 (00000000000000000000000000001101) is 1 - 1 Max gap in 14 (00000000000000000000000000001110) is 0 - 0 Max gap in 15 (00000000000000000000000000001111) is 0 - 0 Max gap in 16 (00000000000000000000000000010000) is 0 - 0 Max gap in 17 (00000000000000000000000000010001) is 3 - 3 Max gap in 18 (00000000000000000000000000010010) is 2 - 2 Max gap in 19 (00000000000000000000000000010011) is 2 - 2 Max gap in 20 (00000000000000000000000000010100) is 1 - 1 Max gap in 21 (00000000000000000000000000010101) is 1 - 1 Max gap in 22 (00000000000000000000000000010110) is 1 - 1 Max gap in 23 (00000000000000000000000000010111) is 1 - 1 Max gap in 24 (00000000000000000000000000011000) is 0 - 0 Max gap in 25 (00000000000000000000000000011001) is 2 - 2 Max gap in 26 (00000000000000000000000000011010) is 1 - 1 Max gap in 27 (00000000000000000000000000011011) is 1 - 1 Max gap in 28 (00000000000000000000000000011100) is 0 - 0 Max gap in 29 (00000000000000000000000000011101) is 1 - 1 Max gap in 30 (00000000000000000000000000011110) is 0 - 0 Max gap in 31 (00000000000000000000000000011111) is 0 - 0 Max gap in 32 (00000000000000000000000000100000) is 0 - 0 Max gap in 33 (00000000000000000000000000100001) is 4 - 4 Max gap in 34 (00000000000000000000000000100010) is 3 - 3 Max gap in 35 (00000000000000000000000000100011) is 3 - 3 Max gap in 36 (00000000000000000000000000100100) is 2 - 2 Max gap in 37 (00000000000000000000000000100101) is 2 - 2 Max gap in 38 (00000000000000000000000000100110) is 2 - 2 Max gap in 39 (00000000000000000000000000100111) is 2 - 2 Max gap in 40 (00000000000000000000000000101000) is 1 - 1 Max gap in 41 (00000000000000000000000000101001) is 2 - 2 Max gap in 42 (00000000000000000000000000101010) is 1 - 1 Max gap in 43 (00000000000000000000000000101011) is 1 - 1 Max gap in 44 (00000000000000000000000000101100) is 1 - 1 Max gap in 45 (00000000000000000000000000101101) is 1 - 1 Max gap in 46 (00000000000000000000000000101110) is 1 - 1 Max gap in 47 (00000000000000000000000000101111) is 1 - 1 Max gap in 48 (00000000000000000000000000110000) is 0 - 0 Max gap in 49 (00000000000000000000000000110001) is 3 - 3 Max gap in 50 (00000000000000000000000000110010) is 2 - 2 Max gap in 51 (00000000000000000000000000110011) is 2 - 2 Max gap in 52 (00000000000000000000000000110100) is 1 - 1 Max gap in 53 (00000000000000000000000000110101) is 1 - 1 Max gap in 54 (00000000000000000000000000110110) is 1 - 1 Max gap in 55 (00000000000000000000000000110111) is 1 - 1 Max gap in 56 (00000000000000000000000000111000) is 0 - 0 Max gap in 57 (00000000000000000000000000111001) is 2 - 2 Max gap in 58 (00000000000000000000000000111010) is 1 - 1 Max gap in 59 (00000000000000000000000000111011) is 1 - 1 Max gap in 60 (00000000000000000000000000111100) is 0 - 0 Max gap in 61 (00000000000000000000000000111101) is 1 - 1 Max gap in 62 (00000000000000000000000000111110) is 0 - 0 Max gap in 63 (00000000000000000000000000111111) is 0 - 0 Max gap in 64 (00000000000000000000000001000000) is 0 - 0 Max gap in 65 (00000000000000000000000001000001) is 5 - 5 Max gap in 66 (00000000000000000000000001000010) is 4 - 4 Max gap in 67 (00000000000000000000000001000011) is 4 - 4 Max gap in 68 (00000000000000000000000001000100) is 3 - 3 Max gap in 69 (00000000000000000000000001000101) is 3 - 3 Max gap in 70 (00000000000000000000000001000110) is 3 - 3 Max gap in 71 (00000000000000000000000001000111) is 3 - 3 Max gap in 72 (00000000000000000000000001001000) is 2 - 2 Max gap in 73 (00000000000000000000000001001001) is 2 - 2 Max gap in 74 (00000000000000000000000001001010) is 2 - 2 Max gap in 75 (00000000000000000000000001001011) is 2 - 2 Max gap in 76 (00000000000000000000000001001100) is 2 - 2 Max gap in 77 (00000000000000000000000001001101) is 2 - 2 Max gap in 78 (00000000000000000000000001001110) is 2 - 2 Max gap in 79 (00000000000000000000000001001111) is 2 - 2 Max gap in 80 (00000000000000000000000001010000) is 1 - 1 Max gap in 81 (00000000000000000000000001010001) is 3 - 3 Max gap in 82 (00000000000000000000000001010010) is 2 - 2 Max gap in 83 (00000000000000000000000001010011) is 2 - 2 Max gap in 84 (00000000000000000000000001010100) is 1 - 1 Max gap in 85 (00000000000000000000000001010101) is 1 - 1 Max gap in 86 (00000000000000000000000001010110) is 1 - 1 Max gap in 87 (00000000000000000000000001010111) is 1 - 1 Max gap in 88 (00000000000000000000000001011000) is 1 - 1 Max gap in 89 (00000000000000000000000001011001) is 2 - 2 Max gap in 90 (00000000000000000000000001011010) is 1 - 1 Max gap in 91 (00000000000000000000000001011011) is 1 - 1 Max gap in 92 (00000000000000000000000001011100) is 1 - 1 Max gap in 93 (00000000000000000000000001011101) is 1 - 1 Max gap in 94 (00000000000000000000000001011110) is 1 - 1 Max gap in 95 (00000000000000000000000001011111) is 1 - 1 Max gap in 96 (00000000000000000000000001100000) is 0 - 0 Max gap in 97 (00000000000000000000000001100001) is 4 - 4 Max gap in 98 (00000000000000000000000001100010) is 3 - 3 Max gap in 99 (00000000000000000000000001100011) is 3 - 3