結果

問題 No.242 ビンゴゲーム
ユーザー ぴろずぴろず
提出日時 2015-07-10 23:19:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 998 ms / 2,000 ms
コード長 1,463 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 78,820 KB
実行使用メモリ 56,392 KB
最終ジャッジ日時 2023-09-22 10:18:38
合計ジャッジ時間 10,214 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
56,124 KB
testcase_01 AC 994 ms
55,796 KB
testcase_02 AC 997 ms
56,392 KB
testcase_03 AC 193 ms
56,168 KB
testcase_04 AC 169 ms
56,364 KB
testcase_05 AC 174 ms
55,720 KB
testcase_06 AC 743 ms
55,884 KB
testcase_07 AC 995 ms
55,636 KB
testcase_08 AC 996 ms
56,240 KB
testcase_09 AC 998 ms
55,880 KB
testcase_10 AC 996 ms
55,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no242;

import java.util.Scanner;


public class Main {


	static double[][] c = new double[100][100];
	static int[] bingo =
		{
			0b00000_00000_00000_00000_11111,
			0b00000_00000_00000_11111_00000,
			0b00000_00000_11111_00000_00000,
			0b00000_11111_00000_00000_00000,
			0b11111_00000_00000_00000_00000,

			0b00001_00001_00001_00001_00001,
			0b00010_00010_00010_00010_00010,
			0b00100_00100_00100_00100_00100,
			0b01000_01000_01000_01000_01000,
			0b10000_10000_10000_10000_10000,

			0b00001_00010_00100_01000_10000,
			0b10000_01000_00100_00010_00001,
		};

	public static void main(String[] args) {
		combInit();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(solve(n));
//		for(int i=1;i<=99;i++) {
//			System.out.println(i + ":" + solve(i));
//		}
	}

	public static double solve(int n) {
		double nncn = comb(99,n);
		double ans = 0;
		for(int i=0;i<(1<<25);i++) {
			int bc = Integer.bitCount(i);
			if (bc > n) {
				continue;
			}
			int count = 0;
			for(int j=0;j<bingo.length;j++) {
				if ((~i & bingo[j]) == 0) {
					count++;
				}
			}
			ans += comb(74, n-bc) * count / nncn;
		}
		return ans;
	}

	public static void combInit() {
		for(int i=0;i<100;i++) {
			c[i][0] = c[i][i] = 1;
		}
		for(int i=1;i<100;i++) {
			for(int j=1;j<i;j++) {
				c[i][j] = c[i-1][j] + c[i-1][j-1];
			}
		}
	}

	public static double comb(int n,int k) {
		if (k < 0) {
			return 0;
		}
		return c[n][k];
	}

}
0