結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2022-12-23 04:41:37 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 5,000 ms |
| コード長 | 959 bytes |
| コンパイル時間 | 1,059 ms |
| コンパイル使用メモリ | 144,236 KB |
| 実行使用メモリ | 19,840 KB |
| 最終ジャッジ日時 | 2024-11-18 03:54:39 |
| 合計ジャッジ時間 | 2,198 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
using namespace std;
int N;
long double ans[101][101][101];
long double f(int a, int b, int c){
if (a < 0 || b < 0 || c < 0) return 0;
if (a == 0 && b == 0 && c == 0) return 0;
if (ans[a][b][c] != -1) return ans[a][b][c];
long double res;
res = f(a-1, b, c) * a + f(a+1, b-1, c) * b + f(a, b+1, c-1) * c + (long double) N;
res /= (long double) (a+b+c);
return ans[a][b][c] = res;
}
int main(){
for (int i=0; i<=100; i++) for (int j=0; j<=100; j++) for (int k=0; k<=100; k++) ans[i][j][k] = -1;
int a=0, b=0, c=0, d;
cin >> N;
for (int i=0; i<N; i++){
cin >> d;
if (d == 0) c++;
else if (d == 1) b++;
else if (d == 2) a++;
}
cout << setprecision(18) << f(a, b, c) << endl;
return 0;
}
srjywrdnprkt