結果

問題 No.108 トリプルカードコンプ
ユーザー chocoruskchocorusk
提出日時 2019-05-28 12:52:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,167 bytes
コンパイル時間 1,129 ms
コンパイル使用メモリ 99,108 KB
実行使用メモリ 8,232 KB
最終ジャッジ日時 2023-10-17 18:22:35
合計ジャッジ時間 1,721 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;
double memo[101][101][101];
double solve(int x, int y, int z){
    if(x==0 && y==0 && z==0) return 0;
    if(memo[x][y][z]) return memo[x][y][z];
    double ret=0;
    if(x) ret+=(double)x/(double)(x+y+z)*((double)(n-y-z)/(double)x+solve(x-1, y+1, z));
    if(y) ret+=(double)y/(double)(x+y+z)*((double)(n-x-z)/(double)y+solve(x, y-1, z+1));
    if(z) ret+=(double)z/(double)(x+y+z)*((double)(n-x-y)/(double)z+solve(x, y, z-1));
    return memo[x][y][z]=ret;
}
int main()
{
    cin>>n;
    int a[110];
    int x=0, y=0, z=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]==0) x++;
        else if(a[i]==1) y++;
        else if(a[i]==2) z++;
    }
    printf("%.7lf\n", solve(x, y, z));
    return 0;
}
0