結果

問題 No.108 トリプルカードコンプ
ユーザー shinchanshinchan
提出日時 2020-03-17 23:39:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 785 bytes
コンパイル時間 1,448 ms
コンパイル使用メモリ 165,484 KB
実行使用メモリ 216,784 KB
最終ジャッジ日時 2023-08-20 19:28:50
合計ジャッジ時間 4,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
216,732 KB
testcase_01 AC 90 ms
216,740 KB
testcase_02 AC 91 ms
216,732 KB
testcase_03 AC 90 ms
216,548 KB
testcase_04 AC 91 ms
216,728 KB
testcase_05 AC 92 ms
216,784 KB
testcase_06 AC 92 ms
216,752 KB
testcase_07 AC 111 ms
216,636 KB
testcase_08 AC 80 ms
216,604 KB
testcase_09 AC 79 ms
216,740 KB
testcase_10 AC 82 ms
216,736 KB
testcase_11 AC 79 ms
216,548 KB
testcase_12 AC 79 ms
216,732 KB
testcase_13 AC 79 ms
216,748 KB
testcase_14 AC 80 ms
216,600 KB
testcase_15 AC 79 ms
216,544 KB
testcase_16 AC 80 ms
216,600 KB
testcase_17 AC 80 ms
216,616 KB
testcase_18 AC 83 ms
216,764 KB
testcase_19 AC 81 ms
216,620 KB
testcase_20 AC 80 ms
216,556 KB
testcase_21 AC 83 ms
216,604 KB
testcase_22 AC 93 ms
216,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
double dp[301][301][301];
int n;
double solve(int i,int j,int k){
	if(dp[i][j][k]>=0)return dp[i][j][k];
	if(!(i|j|k))return 0.0;
	double res=0.0;
	if(i)res+=solve(i-1,j,k)*i;
	if(j)res+=solve(i+1,j-1,k)*j;
	if(k)res+=solve(i,j+1,k-1)*k;
	res+=n;
	res/=(i+j+k);
	return dp[i][j][k]=res;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    int a,c[4]={0};
    for(int i=0;i<n;i++){
    	cin>>a;
    	//c[a]++;
    	if(a<3)c[3-a]++;
    }
    memset(dp,-1,sizeof(dp));
    doublecout(solve(c[1],c[2],c[3]));
    return 0;
}
0