結果

問題 No.108 トリプルカードコンプ
ユーザー IL_mstaIL_msta
提出日時 2015-07-30 20:02:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 1,238 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 85,036 KB
実行使用メモリ 19,716 KB
最終ジャッジ日時 2023-09-24 22:17:31
合計ジャッジ時間 1,920 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 20 ms
19,584 KB
testcase_08 AC 20 ms
19,612 KB
testcase_09 AC 19 ms
19,716 KB
testcase_10 AC 20 ms
19,616 KB
testcase_11 AC 20 ms
19,564 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
10,732 KB
testcase_14 AC 5 ms
10,612 KB
testcase_15 AC 5 ms
10,676 KB
testcase_16 AC 5 ms
10,720 KB
testcase_17 AC 4 ms
10,640 KB
testcase_18 AC 18 ms
18,952 KB
testcase_19 AC 17 ms
18,568 KB
testcase_20 AC 19 ms
19,500 KB
testcase_21 AC 19 ms
19,456 KB
testcase_22 AC 17 ms
18,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

LD X[101][101][101];

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    cout << setprecision(16);//
	
	int N;
	cin>>N;
	int A[100];
	int a,b,c;
	a=b=c=0;

	rep(i,N){
		cin>>A[i];
		switch(A[i]){
		case 0:
			a++;
			break;
		case 1:
			b++;
			break;
		case 2:
			c++;
			break;
		}
	}
	LD sum,temp;
	for(int i=0;i<=N;++i){
		for(int j=0;j<=N;++j){
			for(int k=0;k<=N;++k){
				sum = i+j+k;
				if( sum ){
					temp = 0;
					if(i>0){
						temp += X[i-1][j+1][k] * i;
					}
					if(j>0){
						temp += X[i][j-1][k+1] * j;
					}
					if(k>0){
						temp += X[i][j][k-1] * k;
					}
					X[i][j][k] = (temp + N)/sum;
				}
			}
		}
	}
	P( X[a][b][c] );
	return 0;
}
0