結果

問題 No.302 サイコロで確率問題 (2)
ユーザー motimoti
提出日時 2015-11-16 00:45:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 318 ms / 6,000 ms
コード長 1,552 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 98,024 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 16:42:55
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 226 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 252 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 318 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 14 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,348 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

double CDF(double x, double m, double s) {
  return (erf((x - m) / (sqrt(2) * s))) / 2.0;
}

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;
      }
    }

    R = min(R, 20000LL);

    double ret = 0.0;
    REPLL(i, L, R+1) {
      ret += dp[i];
    }
    printf("%.15Lf\n", ret);
  }
  else {
    double m  = N * 3.5;
    double s  = sqrt(N * 17.5/6.0);
    printf("%.15Lf\n", CDF(R + 0.5, m, s) - CDF(L - 0.5, m, s));
  }

  return 0;
}
0