結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-04-15 04:20:51 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 5,000 ms |
| コード長 | 697 bytes |
| 記録 | |
| コンパイル時間 | 1,279 ms |
| コンパイル使用メモリ | 168,264 KB |
| 実行使用メモリ | 11,960 KB |
| 最終ジャッジ日時 | 2026-03-08 16:06:12 |
| 合計ジャッジ時間 | 2,205 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#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