結果

問題 No.108 トリプルカードコンプ
ユーザー 沙耶花沙耶花
提出日時 2021-10-26 15:58:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 798 bytes
コンパイル時間 4,771 ms
コンパイル使用メモリ 253,776 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-15 14:58:34
合計ジャッジ時間 11,403 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 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 <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000

int n;
double dp[102][102][102];
bool f[102][102][102];

double get(int a,int b,int c){
	if(a==0&&b==0&&c==0)return 0.0;
	int d = n - a - b - c;
	if(f[a][b][c])return dp[a][b][c];
	double ret = 0.0;
	if(a!=0){
		ret += get(a-1,b+1,c) * a / (double)n;
	}
	if(b!=0){
		ret += get(a,b-1,c+1) * b / (double)n;
	}
	if(c!=0){
		ret += get(a,b,c-1) * c / (double)n;
	}
	ret += 1.0;
	ret /= 1-(double)d/(double)n;
	
	dp[a][b][c] = ret;
	return ret;
	
}

int main(){
	
	cin>>n;
	
	vector<int> c(3,0);
	rep(i,n){
		int a;
		cin>>a;
		if(a<3)c[a]++;
	}
	
	cout<<fixed<<setprecision(10)<<get(c[0],c[1],c[2])<<endl;
	
	return 0;
}
0