結果
問題 |
No.108 トリプルカードコンプ
|
ユーザー |
![]() |
提出日時 | 2015-12-06 17:49:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 855 bytes |
コンパイル時間 | 1,350 ms |
コンパイル使用メモリ | 157,800 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2024-09-14 16:00:24 |
合計ジャッジ時間 | 2,677 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:30:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%d", &x); | ~~~~~^~~~~~~~~~
ソースコード
#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]; 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); }