結果

問題 No.108 トリプルカードコンプ
ユーザー h_nosonh_noson
提出日時 2016-03-23 16:51:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 991 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 67,784 KB
実行使用メモリ 7,900 KB
最終ジャッジ日時 2023-07-25 02:40:28
合計ジャッジ時間 2,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 12 ms
7,900 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 8 ms
6,292 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 6 ms
4,908 KB
testcase_22 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

double dp[101][101][101];
double n;

double e(int a, int b, int c) {
    if (dp[a][b][c] > 0)
        return dp[a][b][c];
    if (a+b+c > 0) {
        dp[a][b][c] = n;
        if (a > 0) dp[a][b][c] += e(a-1,b+1,c)*a;
        if (b > 0) dp[a][b][c] += e(a,b-1,c+1)*b;
        if (c > 0) dp[a][b][c] += e(a,b,c-1)*c;
        dp[a][b][c] /= a+b+c;
    }
    return dp[a][b][c];
}

int main() {
    int i, a, b, c;
    cin >> n;
    a = b = c = 0;
    rep (i,n) {
        int x;
        cin >> x;
        if (x == 0)
            a++;
        else if (x == 1)
            b++;
        else if (x == 2)
            c++;
    }
    cout << fixed << setprecision(7);
    cout << e(a,b,c) << endl;
    return 0;
}
0