@@ -0,0 +1,1693 @@
+package euler;%0D%0A%0D%0Aimport java.math.*;%0D%0A%0D%0Apublic class Problem121 %7B%0D%0A%0D%0A%09static MathContext itgr = new MathContext(0, RoundingMode.FLOOR);%0D%0A%09static BigDecimal total = new BigDecimal(%2221%22);%0D%0A%09static int scale = 50;%0D%0A%09static int rounds = 15;%0D%0A%09static int%5B%5D ps = null;%0D%0A%09static int m = 10;%0D%0A%09static long pSum = 0;%0D%0A//%09static ArrayList winCombs = new ArrayList%3CString%3E();%0D%0A%09%09%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09System.out.println(%22Solve problem 121%22);%0D%0A%09%09int maxRisedBits = rounds %25 2 == 0 ? (int) Math.ceil((rounds - 1) / 2) : (int) Math.ceil((rounds - 1) / 2);%0D%0A%09%09ps = new int%5Brounds%5D;%0D%0A%09%09m = 1 %3C%3C rounds;%0D%0A%09%09System.out.println(%22rounds = %22 + rounds + %22 maxRisedBits = %22 + maxRisedBits + %22 m = %22 + m);%0D%0A%09%09for (int i = 0; i %3C m; i++) %7B%0D%0A%09%09%09if (Integer.bitCount(i) %3C= maxRisedBits) %7B%0D%0A%09%09%09%09String bits = Integer.toBinaryString(i);%0D%0A%09%09%09%09int leadingZeros = rounds - bits.length();%0D%0A%09%09%09%09for (int z = 0; z %3C leadingZeros; z++) %7B%0D%0A%09%09%09%09%09bits = %220%22 + bits;%0D%0A%09%09%09%09%7D%0D%0A//%09%09%09%09winCombs.add(bits);%0D%0A%09%09%09%09long pProb = pProb(bits);%0D%0A%09%09%09%09System.out.println(%22bits = %22 + bits + %22 lz=%22 + leadingZeros + %22 prob = %22 + pProb);%0D%0A%09%09%09%09pSum += pProb;%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09System.out.println(%22pSum = %22 + pSum);%0D%0A%09%09long q = fact(rounds + 1);%0D%0A%09%09System.out.println(%22fact (%22 + (rounds + 1) + %22) = %22 +  q);%0D%0A%09%09System.out.println(%221/prob = %22 + q / pSum);%0D%0A%09%7D%0D%0A%09%0D%0A%09public static long fact(int n) %7B%0D%0A%09%09long retval = 1l;%0D%0A%09%09if (n %3E 1l) %7B%0D%0A%09%09%09return n * fact(n - 1);%0D%0A%09%09%7D else %7B%0D%0A%09%09%09return 1;%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09public static long pProb(String s) %7B%0D%0A%09%09char%5B%5D chrs = s.toCharArray();%0D%0A%09%09long retval = 1l;%0D%0A%09%09for (long i = 0; i %3C s.length(); i++) %7B%0D%0A%09%09%09if (chrs%5B(int) i%5D == '1') %7B%0D%0A%09%09%09%09retval *= (i + 1);%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return retval;%0D%0A%09%7D%0D%0A%09%0D%0A%7D

add solution for problem 121