結果

問題 No.108 トリプルカードコンプ
ユーザー kusainu7kusainu7
提出日時 2021-05-29 19:07:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 72,676 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-04-25 14:58:59
合計ジャッジ時間 1,587 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 14 ms
13,176 KB
testcase_08 AC 14 ms
13,192 KB
testcase_09 AC 14 ms
13,640 KB
testcase_10 AC 14 ms
13,264 KB
testcase_11 AC 14 ms
13,172 KB
testcase_12 WA -
testcase_13 AC 4 ms
8,392 KB
testcase_14 AC 4 ms
8,396 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 4 ms
8,132 KB
testcase_18 AC 13 ms
12,868 KB
testcase_19 AC 12 ms
12,640 KB
testcase_20 AC 14 ms
13,516 KB
testcase_21 AC 14 ms
13,348 KB
testcase_22 AC 12 ms
12,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

double c[110][110][110] = {};

void dp(int n, int *a) {
	c[n][n][n] = 0;
	for (int i=n; i>=0; i--) {
		for (int j=n; j>=0; j--) {
			for (int k=n; k>=0; k--) {
				if (k>=n) {
					continue;
				}
				c[i][j][k] = 1.0*n/(n-k);
				if (i!=n) c[i][j][k] += c[i+1][j][k]*(n-i)/(n-k);
				if (i!=j) c[i][j][k] += c[i][j+1][k]*(i-j)/(n-k);
				if (j!=k) c[i][j][k] += c[i][j][k+1]*(j-k)/(n-k);

			}
		}
	}
}

int main() {
	int n, x;
	cin >> n;
	int a[4] = {};

	for (int i=0; i<n; i++) {
		cin >> x;
		if (x>3) {
			a[3]++;
		} else if (x!=0) {
			a[x]++;
		}
	}
	
	for (int i=2; i>0; i--) {
		a[i] += a[i+1];
	}
	
	dp(n, a);

	cout << c[a[1]][a[2]][a[3]] << '\n';
}
0