結果
| 問題 |
No.108 トリプルカードコンプ
|
| コンテスト | |
| ユーザー |
nemakura3
|
| 提出日時 | 2019-08-08 19:40:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,061 bytes |
| コンパイル時間 | 1,628 ms |
| コンパイル使用メモリ | 165,948 KB |
| 実行使用メモリ | 14,208 KB |
| 最終ジャッジ日時 | 2024-07-18 20:56:02 |
| 合計ジャッジ時間 | 2,284 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 3 |
ソースコード
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define rrep(i,a,b) for (int (i) = (a); (i) >= (b); --(i))
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int N;
int c0, c1, c2;
double dp[110][110][110];
double dfs(int i, int j, int k) {
if (dp[i][j][k] >= 0) return dp[i][j][k];
if (i == 0 && j == 0 && k == 0) return 0;
double res = N;
if (i > 0) res += dfs(i - 1, j + 1, k) * i;
if (j > 0) res += dfs(i, j - 1, k + 1) * j;
if (k > 0) res += dfs(i, j, k - 1) * k;
res /= (double)(i + j + k);
return dp[i][j][k] = res;
}
int main() {
cin >> N;
rep(i, 0, N) {
int a;
cin >> a;
if (a == 0) ++c0;
if (a == 1) ++c1;
if (a == 2) ++c2;
}
memset(dp, -1, sizeof(dp));
cout << dfs(c0, c1, c2) << endl;
return 0;
}
nemakura3