結果

問題 No.108 トリプルカードコンプ
ユーザー kk
提出日時 2021-03-10 15:45:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 769 bytes
コンパイル時間 2,037 ms
コンパイル使用メモリ 195,620 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2024-04-20 10:39:43
合計ジャッジ時間 3,173 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
11,744 KB
testcase_01 AC 11 ms
11,728 KB
testcase_02 AC 10 ms
11,740 KB
testcase_03 AC 10 ms
11,764 KB
testcase_04 AC 9 ms
11,836 KB
testcase_05 AC 9 ms
11,820 KB
testcase_06 AC 10 ms
11,732 KB
testcase_07 AC 10 ms
11,868 KB
testcase_08 AC 10 ms
11,808 KB
testcase_09 AC 9 ms
11,972 KB
testcase_10 AC 9 ms
11,952 KB
testcase_11 AC 9 ms
11,780 KB
testcase_12 AC 9 ms
11,744 KB
testcase_13 AC 9 ms
11,824 KB
testcase_14 AC 9 ms
11,748 KB
testcase_15 AC 9 ms
11,756 KB
testcase_16 AC 9 ms
11,872 KB
testcase_17 AC 9 ms
11,740 KB
testcase_18 AC 10 ms
11,852 KB
testcase_19 AC 9 ms
11,728 KB
testcase_20 AC 10 ms
11,844 KB
testcase_21 AC 11 ms
11,780 KB
testcase_22 AC 10 ms
11,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

double dp[101][101][101];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;
  
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      for (int k = 0; k <= 100; k++) {
        if (i + j + k == 0) continue;
        double sum = 1.0;
        if (i) sum += 1.0 * i / n * dp[i-1][j+1][k];
        if (j) sum += 1.0 * j / n * dp[i][j-1][k+1];
        if (k) sum += 1.0 * k / n * dp[i][j][k-1];
        sum *= 1.0 * n / (i + j + k);
        dp[i][j][k] = sum;
      }
    }
  }

  int rm[4] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    rm[max(3 - a, 0)]++;
  }

  cout << fixed << setprecision(12) << dp[rm[3]][rm[2]][rm[1]] << endl;
  
  return 0;
}
0