/** * Suit Distribution Problem. * * @author John Paxton * @version May 20, 2014 */ import java.io.*; import java.util.Scanner; public class Suit { public static void main (String [] args) throws FileNotFoundException { Scanner in = new Scanner (new File ("suit.in")); PrintWriter out = new PrintWriter (new File ("suit.out")); int hand_1 = in.nextInt(); int hand_2 = in.nextInt(); while ((hand_1 != -1) && (hand_2 != -1)) { out.print(hand_1 + "-" + hand_2 + " split: "); out.format("%.8f\n", calculate(hand_1, hand_2)); hand_1 = in.nextInt(); hand_2 = in.nextInt(); } out.close(); } private static double calculate (int hand_1, int hand_2) { double answer; answer = combo(hand_1 + hand_2, hand_1) * combo(26 - hand_1 - hand_2, 13 - hand_1) / combo(26, 13); if (hand_1 != hand_2) { answer *= 2; } return answer; } private static double combo (int n, int k) { double answer = 1; for (int i = k + 1; i <= n; i++) { answer *= i; } for (int i = 2; i <= n - k; i++) { answer /= i; } return answer; } }