結果
問題 | No.108 トリプルカードコンプ |
ユーザー | tottoripaper |
提出日時 | 2019-03-08 14:26:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,123 bytes |
コンパイル時間 | 1,440 ms |
コンパイル使用メモリ | 165,312 KB |
実行使用メモリ | 15,788 KB |
最終ジャッジ日時 | 2023-09-05 19:39:00 |
合計ジャッジ時間 | 8,185 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
11,580 KB |
testcase_01 | AC | 5 ms
11,720 KB |
testcase_02 | AC | 5 ms
11,556 KB |
testcase_03 | AC | 5 ms
11,548 KB |
testcase_04 | AC | 6 ms
11,768 KB |
testcase_05 | AC | 6 ms
11,556 KB |
testcase_06 | AC | 5 ms
11,544 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 | -- | - |
ソースコード
#include <bits/stdc++.h> #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple<int,int>; int N; int A[100]; double dp[101][101][101]; double rec(int n0, int n1, int n2){ if(n0 + n1 + n2 == 0){ return 0; } double p0 = 1.0 * n0 / N, p1 = 1.0 * n1 / N, p2 = 1.0 * n2 / N, p = p0 + p1 + p2; double e = 1; if(n0 > 0){ e += p0 * rec(n0 - 1, n1 + 1, n2); } if(n1 > 0){ e += p1 * rec(n0, n1 - 1, n2 + 1); } if(n2 > 0){ e += p2 * rec(n0, n1, n2 - 1); } e /= p; return dp[n0][n1][n2] = e; } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N; for(int i=0;i<N;++i){ std::cin >> A[i]; } std::fill(&dp[0][0][0], &dp[0][0][0] + 101 * 101 * 101, -1); double e = rec(std::count(A, A + N, 0), std::count(A, A + N, 1), std::count(A, A + N, 2)); printf("%.10f\n", e); }