結果

問題 No.108 トリプルカードコンプ
ユーザー face4face4
提出日時 2019-01-25 22:21:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 69,552 KB
実行使用メモリ 8,036 KB
最終ジャッジ日時 2023-10-14 09:54:43
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 12 ms
7,928 KB
testcase_08 AC 7 ms
8,036 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 3 ms
4,488 KB
testcase_14 AC 3 ms
4,432 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 3 ms
4,392 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 10 ms
7,420 KB
testcase_19 AC 7 ms
6,948 KB
testcase_20 AC 5 ms
5,476 KB
testcase_21 AC 8 ms
6,980 KB
testcase_22 AC 3 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// EDPC-J sushiを勉強したのでついでに
#include<iostream>
#include<iomanip>
using namespace std;

double dp[101][101][101] = {};
int n;

double dfs(int i, int j, int k){
    if(dp[i][j][k] > 0) return dp[i][j][k];
    if(i+j+k == 0)   return 0;

    double ret = 1.0;
    if(i)   ret += (double)i / n * dfs(i-1, j, k);
    if(j)   ret += (double)j / n * dfs(i+1, j-1, k);
    if(k)   ret += (double)k / n * dfs(i, j+1, k-1);

    ret *= (double)n / (i+j+k);

    return dp[i][j][k] = ret;
}

int main(){
    int a, cnt[3] = {};
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a;
        if(a < 3)   cnt[3-a-1]++;
    }

    cout << fixed << setprecision(12) << dfs(cnt[0], cnt[1], cnt[2]) << endl;
    
    return 0;
}
0