結果
問題 | No.108 トリプルカードコンプ |
ユーザー | kagamiz |
提出日時 | 2015-12-06 17:50:20 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 861 bytes |
コンパイル時間 | 1,237 ms |
コンパイル使用メモリ | 144,064 KB |
実行使用メモリ | 20,172 KB |
最終ジャッジ日時 | 2023-10-12 17:28:22 |
合計ジャッジ時間 | 2,311 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
19,912 KB |
testcase_01 | AC | 7 ms
19,836 KB |
testcase_02 | AC | 7 ms
19,824 KB |
testcase_03 | AC | 7 ms
20,040 KB |
testcase_04 | AC | 7 ms
19,864 KB |
testcase_05 | AC | 7 ms
19,968 KB |
testcase_06 | AC | 7 ms
19,908 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 7 ms
20,044 KB |
testcase_11 | AC | 7 ms
19,832 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int N; double memo[128][128][128]; double calc(int zero, int one, int two) { if (zero + one + two == 0) return (0); if (memo[zero][one][two] >= 0) return (memo[zero][one][two]); double ret = 1; if (zero) ret += zero * 1. / N * calc(zero - 1, one + 1, two); if (one) ret += one * 1. / N * calc(zero, one - 1, two + 1); if (two) ret += two * 1. / N * calc(zero, one, two - 1); if (zero + one + two != N) ret = N * 1. / (N - zero - one - two) * ret; return (memo[zero][one][two] = ret); } int main() { int ct[3] = {0}; scanf("%d", &N); for (int i = 0; i < N; i++){ int x; scanf("%d", &x); if (x < 3) ct[x]++; } for (int i = 0; i < 128; i++) for (int j = 0; j < 128; j++) for (int k = 0; k < 128; k++) memo[i][j][k] = -1; printf("%.10lf\n", calc(ct[0], ct[1], ct[2])); return (0); }