結果

問題 No.302 サイコロで確率問題 (2)
ユーザー motimoti
提出日時 2015-11-15 21:29:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 317 ms / 6,000 ms
コード長 1,560 bytes
コンパイル時間 983 ms
コンパイル使用メモリ 99,456 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 16:34:42
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define REPLL(i,a,b) for(ll i=a;i<(ll)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)

using ll  = long long;
ll const inf = 1LL<<59;

#define double long double

int main() {

  ll N, L, R; cin >> N >> L >> R;
  L = max(N, L);
  R = min(6 * N, R);

  if(N <= 3000) {
    if(L > inf) {
      cout << "0\n";
    }

    double dp[22222]; // reuse array
    dp[0] = 1.0;
    rep(i, N) {
      for(int x=20000; x>=0; x--) {
        if(!dp[x]) { continue; }
        REP(k, 1, 7) {
          dp[x + k] += dp[x] / 6.0;
        }
        dp[x] = 0.0;
      }
    }

    double ret = 0.0;
    REPLL(i, max(0LL, L), min(R+1, 20000LL)) {
      ret += dp[i];
    }
    printf("%.15Lf\n", ret);
  }
  else {
    double m  = N * 3.5;
    double s  = sqrt(N * 17.5/6.0);
    double supremum = erf((R + 0.5 - m) / (sqrt(2) * s));
    double infimum  = erf((L - 0.5 - m) / (sqrt(2) * s));
    printf("%.15Lf\n", (supremum - infimum) / 2.0);
  }

  return 0;
}
0