結果

問題 No.108 トリプルカードコンプ
ユーザー Hoi_koroHoi_koro
提出日時 2016-11-24 21:57:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 1,772 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 102,892 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2023-08-18 07:10:56
合計ジャッジ時間 1,995 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,592 KB
testcase_01 AC 4 ms
11,776 KB
testcase_02 AC 4 ms
11,720 KB
testcase_03 AC 4 ms
11,700 KB
testcase_04 AC 4 ms
11,712 KB
testcase_05 AC 4 ms
11,612 KB
testcase_06 AC 5 ms
11,712 KB
testcase_07 AC 7 ms
11,704 KB
testcase_08 AC 7 ms
11,612 KB
testcase_09 AC 7 ms
11,548 KB
testcase_10 AC 7 ms
11,588 KB
testcase_11 AC 7 ms
11,736 KB
testcase_12 AC 4 ms
11,584 KB
testcase_13 AC 5 ms
11,708 KB
testcase_14 AC 5 ms
11,584 KB
testcase_15 AC 4 ms
11,544 KB
testcase_16 AC 4 ms
11,592 KB
testcase_17 AC 4 ms
11,696 KB
testcase_18 AC 6 ms
11,712 KB
testcase_19 AC 6 ms
11,588 KB
testcase_20 AC 6 ms
11,592 KB
testcase_21 AC 8 ms
11,708 KB
testcase_22 AC 7 ms
11,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int tmp,n,cnt[4]={};
    double dp[101][101][101]={};
    cin >> n;
    REP(i,n){
        cin >> tmp;
        if(tmp<3)cnt[3-tmp]++;
    }
    REP(i,n+1){
        REP(j,n+1-i){
            REP(k,n+1-i-j){
                //cout << i << ' ' << j << ' '<< k << ' '<< dp[i][j][k]<<endl;
                if(j!=0){
                    dp[i+1][j-1][k]+=(dp[i][j][k]+(double)n/(i+j+k))*(double)(i+1)/(i+j+k);
                }
                if(k!=0){
                    dp[i][j+1][k-1]+=(dp[i][j][k]+(double)n/(i+j+k))*(double)(j+1)/(i+j+k);
                }
                if(i+j+k<n){
                    dp[i][j][k+1]+=(dp[i][j][k]+(double)n/(i+j+k+1))*(double)(k+1)/(i+j+k+1);
                }
            }
        }
    }
    cout <<fixed<<setprecision(10);
    cout<<dp[cnt[3]][cnt[2]][cnt[1]]<<endl;

    return 0;
}
0