結果

問題 No.108 トリプルカードコンプ
ユーザー tubo28tubo28
提出日時 2015-07-26 16:22:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 144,708 KB
実行使用メモリ 14,400 KB
最終ジャッジ日時 2023-09-22 23:30:34
合計ジャッジ時間 2,929 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)

int n;

double dp[111][111][111];
double rec(int a, int b, int c){
    double & res = dp[a][b][c];
    if(res != -1) return res;
    if(a+b+c == 0) return res = 0;
    res = 0;
    if(a) res += rec(a-1,b+1,c) * a/(a+b+c);
    if(b) res += rec(a,b-1,c+1) * b/(a+b+c);
    if(c) res += rec(a,b,c-1) * c/(a+b+c);
    res += 1.*n/(a+b+c);
    return res;
}

int main(){
    cin >> n;
    int a = 0, b = 0, c = 0;
    rep(i,n){
        int x;
        cin >> x;
        int d = 3-x;
        if(d==0) a++;
        if(d==1) b++;
        if(d==2) c++;
    }
    rep(i,111)rep(j,111)rep(k,111) dp[i][j][k] = -1;
    printf("%.10lf\n",rec(a,b,c));
}
0