結果
| 問題 |
No.108 トリプルカードコンプ
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-04-15 04:20:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 697 bytes |
| コンパイル時間 | 324 ms |
| コンパイル使用メモリ | 52,996 KB |
| 最終ジャッジ日時 | 2024-11-14 19:40:58 |
| 合計ジャッジ時間 | 709 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:5: error: ‘vector’ was not declared in this scope
29 | vector<int> a(n);
| ^~~~~~
main.cpp:5:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
4 | #include <cstring>
+++ |+#include <vector>
5 | using namespace std;
main.cpp:29:12: error: expected primary-expression before ‘int’
29 | vector<int> a(n);
| ^~~
main.cpp:30:17: error: ‘a’ was not declared in this scope
30 | for(int& e: a) {
| ^
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
double memo[101][101][101];
int n;
double func(int a, int b, int c)
{
if (a==0 and b==0 and c==0) return 0;
auto& res=memo[a][b][c];
// if (!isnan(res)) return res;
if (res==res) return res;
int s=a+b+c;
res=(double)n/s;
if (a) res+=func(a-1, b+1, c)*a/s;
if (b) res+=func(a, b-1, c+1)*b/s;
if (c) res+=func(a, b, c-1)*c/s;
return res;
}
int main()
{
cin>>n;
int m[3]={};
vector<int> a(n);
for(int& e: a) {
cin>>e;
if (e<3) m[e]++;
}
memset(memo, -1, sizeof(memo));
printf("%.9f\n", func(m[0], m[1], m[2]));
}
hogeover30