結果

問題 No.108 トリプルカードコンプ
ユーザー minatominato
提出日時 2020-03-21 07:09:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 1,273 bytes
コンパイル時間 1,783 ms
コンパイル使用メモリ 173,276 KB
実行使用メモリ 15,864 KB
最終ジャッジ日時 2023-08-22 18:10:09
合計ジャッジ時間 2,751 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

#define EPS (1e-10)
int N;
double dp[300][300][300];
double func(int a, int b, int c) {
	if (a+b+c==0) return 0;
	if (dp[a][b][c] > EPS) return dp[a][b][c];
	dp[a][b][c] = N;
	if (a) dp[a][b][c] += func(a-1,b+1,c)*a;
	if (b) dp[a][b][c] += func(a,b-1,c+1)*b;
	if (c) dp[a][b][c] += func(a,b,c-1)*c;
	dp[a][b][c] /= (a+b+c);
	return dp[a][b][c]; 
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	cin >> N;
	int a = 0, b = 0, c = 0;
	rep(i,N) {
		int A; cin >> A;
		if (A==0) a++;
		if (A==1) b++;
		if (A==2) c++;
	}

	cout << fixed << setprecision(10) << func(a,b,c) << ln;
}
0