結果

問題 No.108 トリプルカードコンプ
ユーザー なおなお
提出日時 2014-12-21 23:53:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 809 bytes
コンパイル時間 3,110 ms
コンパイル使用メモリ 144,072 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-09-02 21:03:50
合計ジャッジ時間 9,256 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
const int MOD = 1000000007;

int k[4];

double dfs(int N, int k0, int k1, int k2, int k3, int cnt){
    if(k0 == 0 && k1 == 0 && k2 == 0) return 0;
    if(cnt>100) return 0;

    double res = 1;
    if(k0 > 0) res += dfs(N, k0-1, k1+1, k2,   k3    , cnt+1) * k0 / N;
    if(k1 > 0) res += dfs(N, k0,   k1-1, k2+1, k3    , cnt+1) * k1 / N;
    if(k2 > 0) res += dfs(N, k0,   k1,   k2-1, k3 + 1, cnt+1) * k2 / N;
    if(k3 > 0) res += dfs(N, k0,   k1,   k2,   k3    , cnt+1) * k3 / N;
    return res;
}

int main(){
    int N; cin >> N;
    REP(i,N){
        int A; cin >> A;
        if(A < 3) k[A]++;
    }

    cout << dfs(N, k[0],k[1],k[2],N-k[0]-k[1]-k[2],0) << endl;
    return 0;
}
0