結果

問題 No.302 サイコロで確率問題 (2)
ユーザー 0w10w1
提出日時 2017-12-30 22:55:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,058 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 203,964 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 11:10:27
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

double naive_solve(long long n, long long l, long long r) {
  l = std::min(6 * n, std::max(n, l));
  r = std::min(6 * n, r);
  std::vector<std::vector<double>> dp(2, std::vector<double>(r + 6 + 1));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    std::fill(dp[~i & 1].begin(), dp[~i & 1].end(), 0);
    for (int j = i; j <= 6 * i; ++j) {
      for (int d = 1; d <= 6; ++d) {
        dp[~i & 1][j + d] += dp[i & 1][j] / 6;
      }
    }
  }
  return std::accumulate(dp[n & 1].begin() + l, dp[n & 1].begin() + r + 1, 0.0);
}

double extreme_solve(long long n, long long l, long long r) {
  double avg = n * 3.5;
  double var = n * 35 / 12;
  return (std::erf((r + 0.5 - avg) / std::sqrt(2 * var)) - std::erf((l - 0.5 - avg) / std::sqrt(2 * var))) / 2;
}

signed main() {
  long long N, L, R;
  std::cin >> N >> L >> R;
  if (N < 8000) std::cout << std::fixed << std::setprecision(6) << naive_solve(N, L, R) << std::endl;
  else std::cout << std::fixed << std::setprecision(6) << extreme_solve(N, L, R) << std::endl;
  return 0;
}
0