結果

問題 No.108 トリプルカードコンプ
ユーザー kk
提出日時 2021-03-10 15:35:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 804 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 195,356 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-20 10:27:32
合計ジャッジ時間 3,202 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,904 KB
testcase_01 AC 10 ms
11,776 KB
testcase_02 AC 9 ms
11,776 KB
testcase_03 AC 9 ms
11,776 KB
testcase_04 AC 8 ms
11,772 KB
testcase_05 AC 8 ms
11,744 KB
testcase_06 AC 8 ms
11,864 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 10 ms
11,820 KB
testcase_11 AC 10 ms
11,784 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 <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];
        if (i + j + k < n)
          sum /= (1 - 1.0 * (i + j + k) / n);
        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