結果

問題 No.242 ビンゴゲーム
ユーザー ぴろずぴろず
提出日時 2015-07-10 23:22:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 2,881 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 77,528 KB
実行使用メモリ 54,348 KB
最終ジャッジ日時 2024-07-08 02:18:05
合計ジャッジ時間 3,934 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
54,164 KB
testcase_01 AC 115 ms
54,348 KB
testcase_02 AC 114 ms
54,280 KB
testcase_03 AC 100 ms
52,688 KB
testcase_04 AC 125 ms
54,060 KB
testcase_05 AC 124 ms
53,948 KB
testcase_06 AC 101 ms
53,156 KB
testcase_07 AC 118 ms
54,040 KB
testcase_08 AC 115 ms
53,836 KB
testcase_09 AC 102 ms
53,088 KB
testcase_10 AC 115 ms
53,992 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 double[] magic = {-1,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000001678,0.0000010067,0.0000035233,0.0000093956,0.0000211400,0.0000422800,0.0000775134,0.0001328801,0.0002159301,0.0003358913,0.0005038369,0.0007328537,0.0010382094,0.0014375207,0.0019509209,0.0026012279,0.0034141117,0.0044182622,0.0056455572,0.0071312301,0.0089140377,0.0110364276,0.0135447066,0.0164892080,0.0199244597,0.0239093516,0.0285073039,0.0337864342,0.0398197260,0.0466851961,0.0544660621,0.0632509108,0.0731338656,0.0842147543,0.0965992770,0.1103991737,0.1257323923,0.1427232561,0.1615026319,0.1822080976,0.2049841098,0.2299821719,0.2573610019,0.2872866998,0.3199329157,0.3554810174,0.3941202585,0.4360479455,0.4814696065,0.5305991582,0.5836590741,0.6408805518,0.7025036819,0.7687776142,0.8399607265,0.9163207927,0.9981351491,1.0856908639,1.1792849039,1.2792243026,1.3858263278,1.4994186497,1.6203395086,1.7489378823,1.8855736543,2.0306177815,2.1844524621,2.3474713024,2.5200794865,2.7026939420,2.8957435092,3.0996691084,3.3149239076,3.5419734904,3.7812960237,4.0333824251,4.2987365321,4.5778752679,4.8713288107,5.1796407607,5.5033683083,5.8430824014,6.1993679137,6.5728238121,6.9640633248,7.3737141086,7.8024184172,8.2508332687,8.7196306136,9.2094975020,9.7211362521,10.2552646176,10.8126159555,11.3939393939,12.0000000000,
	};

	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(String.format("%.10f", solve(i)));
//		}
		System.out.println(String.format("%.10f", magic[sc.nextInt()]));
	}

	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