結果

問題 No.574 正多面体サイコロ
ユーザー pekempeypekempey
提出日時 2017-10-06 23:36:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 78,828 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-10 17:33:53
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main() {
  int F, N, K;
  cin >> F >> N >> K;

  double ans = 0;

  for (int t = 1; t <= F; t++) {
    static double dp0[101][101];
    static double dp1[101][101];
    fill_n(*dp0, 101 * 101, 0.0);
    dp0[0][0] = 1;

    for (int k = 0; k < N; k++) {
      fill_n(*dp1, 101 * 101, 0.0);
      for (int i = 0; i <= k; i++) {
        for (int j = 0; i + j <= k; j++) {
          dp1[i + 1][j] += 1.0 * (F - t) / F * dp0[i][j];
          dp1[i][j + 1] += 1.0 / F * dp0[i][j];
          dp1[i][j] += 1.0 * (t - 1) / F * dp0[i][j];
        }
      }
      swap(dp0, dp1);
    }
    for (int i = 0; i <= N; i++) {
      for (int j = 0; i + j <= N; j++) {
        if (i + 1 <= K && K <= i + j) {
          ans += t * dp0[i][j];
        }
      }
    }
  }
  printf("%.20f\n", ans);
}
0