結果

問題 No.108 トリプルカードコンプ
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-11-15 03:49:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 732 bytes
コンパイル時間 1,300 ms
コンパイル使用メモリ 164,628 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-17 06:53:07
合計ジャッジ時間 8,223 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,508 KB
testcase_01 AC 2 ms
4,504 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



int N;
int A[101];
//-----------------------------------------------------------------
double rec(int a, int b, int c) {
	int sm = a + b + c;
	if (sm == 0) return 0;

	double ret = ((double)N / (double)sm);
	
	if (0 < a) ret += rec(a - 1, b + 1, c) * ((double)a / (double)sm);
	if (0 < b) ret += rec(a, b - 1, c + 1) * ((double)b / (double)sm);
	if (0 < c) ret += rec(a, b, c - 1) * ((double)c / (double)sm);

	return ret;
}

int main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	int a = 0, b = 0, c = 0;
	rep(i, 0, N) {
		if (A[i] == 0)
			a++;
		else if (A[i] == 1)
			b++;
		else if (A[i] == 2)
			c++;
	}

	printf("%.10f\n", rec(a, b, c));
}
0