結果

問題 No.108 トリプルカードコンプ
ユーザー h_nosonh_noson
提出日時 2016-03-23 16:47:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 60,020 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-09 21:06:05
合計ジャッジ時間 1,334 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
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[100][100][100];
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 << e(a,b,c) << endl;
    return 0;
}
0