結果
| 問題 |
No.108 トリプルカードコンプ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-04 17:43:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 747 bytes |
| コンパイル時間 | 2,091 ms |
| コンパイル使用メモリ | 195,364 KB |
| 最終ジャッジ日時 | 2025-02-07 02:44:33 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Int long long
double dp[109][109][109];
int N;
double rec(int i, int j, int k) {
if (i < 0 || j < 0 || k < 0) return 0LL;
if (dp[i][j][k] != -1) return dp[i][j][k];
double total = i + j + k;
double res = N / total;
res += rec(i - 1, j + 1, k) * i / total;
res += rec(i, j - 1, k + 1) * j / total;
res += rec(i, j, k - 1) * k / total;
return dp[i][j][k] = res;
}
int main() {
cin >> N;
vector<int> cnt(3);
rep(i, N) {
int a;
cin >> a;
if (a < 3) cnt[a]++;
}
rep(i, 109) {
rep(j, 109) { fill(dp[i][j], dp[i][j] + 109, -1); }
}
dp[0][0][0] = 0LL;
cout << rec(cnt[0], cnt[1], cnt[2]) << endl;
}