結果

問題 No.108 トリプルカードコンプ
ユーザー hashiryohashiryo
提出日時 2019-05-21 16:27:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 1,452 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 97,392 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2023-10-17 10:39:11
合計ジャッジ時間 3,845 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int N;
double dp[110][110][110];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  int cnt[3]={0};
  repeat(i,N){
    int A;cin>>A;
    cnt[2] += A>=3;
    cnt[1] += A>=2;
    cnt[0] += A>=1;
  }
  for(int i=N;i>=0;i--){
    for(int j=i;j>=0;j--){
      for(int k=min(j,N-1);k>=0;k--){
        dp[i][j][k] = dp[i+1][j][k]*(N-i)/(N-k)+dp[i][j+1][k]*(i-j)/(N-k)+dp[i][j][k+1]*(j-k)/(N-k)+(double)N/(N-k);
      }
    }
  }
  //debugArray(cnt,3);
  printf("%.7lf\n",dp[cnt[0]][cnt[1]][cnt[2]]);
  return 0;
}
0