結果

問題 No.108 トリプルカードコンプ
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-28 18:39:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,454 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 65,648 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2023-08-13 13:08:24
合計ジャッジ時間 1,519 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,784 KB
testcase_01 AC 5 ms
11,728 KB
testcase_02 AC 5 ms
11,732 KB
testcase_03 AC 5 ms
11,772 KB
testcase_04 AC 5 ms
11,776 KB
testcase_05 AC 4 ms
11,908 KB
testcase_06 AC 5 ms
11,780 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
11,868 KB
testcase_11 AC 5 ms
11,736 KB
testcase_12 AC 5 ms
11,932 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int n, a[12];
double dp[102][102][102];

double solve(int c3, int c2, int c1){
	if(dp[c3][c2][c1] != -1) return dp[c3][c2][c1];

	double ret = 1.0;
	// if(c3 > 0) ret += dp[c3 - 1][c2 + 1][c1] * ((double)c3 / (double)(n));
	// if(c3 > 0) ret += solve(c3 - 1, c2 + 1, c1) * ((double)c3 / (double)(n));
	if(c3 > 0) ret += solve(c3 - 1, c2 + 1, c1) * (double)c3 / (double)(n);
	// if(c2 > 0) ret += dp[c3][c2 - 1][c1 + 1] * ((double)c2 / (double)(n));
	// if(c2 > 0) ret += solve(c3, c2 - 1, c1 + 1) * ((double)c2 / (double)(n));
	if(c2 > 0) ret += solve(c3, c2 - 1, c1 + 1) * (double)c2 / (double)(n);
	// if(c1 > 0) ret += dp[c3][c2][c1 - 1] * ((double)c1 / (double)(n));
	// if(c1 > 0) ret += solve(c3, c2, c1 - 1) * ((double)c1 / (double)(n));
	if(c1 > 0) ret += solve(c3, c2, c1 - 1) * (double)c1 / (double)(n);
	// return dp[c3][c2][c1] = ((double)n / (double)(c1 + c2 + c3)) * ret;
	return dp[c3][c2][c1] = ret * (double)n / (double)(c1 + c2 + c3);

}

int main(void){
	cin >> n;
	int cnt3 = 0, cnt2 = 0, cnt1 = 0;
	rep(i, n){
		cin >> a[i];
		if(a[i] == 0) cnt3++;
		else if(a[i] == 1) cnt2++;
		else if(a[i] == 2) cnt1++;
	}

	rep(i, 102)rep(j, 102)rep(k, 102) dp[i][j][k] = -1;
	dp[0][0][0] = 0.0;
	printf("%.12f\n", solve(cnt3, cnt2, cnt1));
	return 0;
}
0