結果

問題 No.302 サイコロで確率問題 (2)
ユーザー sugim48sugim48
提出日時 2015-11-13 23:05:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,353 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 77,576 KB
実行使用メモリ 7,912 KB
最終ジャッジ日時 2023-10-11 16:24:21
合計ジャッジ時間 13,573 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

double f(double mu, double bunsan, double x) {
	return exp(-(x - mu) * (x - mu) / 2 / bunsan) / sqrt(2 * M_PI * bunsan);
}

int main() {
	ll N, L, R; cin >> N >> L >> R;
	if (N <= 8000) {
		vector<double> dp(N * 6 + 1);
		dp[0] = 1;
		for (int t = 0; t < N; t++)
			for (int i = t * 6; i >= 0; i--) {
				for (int j = 1; j <= 6; j++)
					dp[i + j] += dp[i] / 6;
				dp[i] = 0;
			}
		double sum = 0;
		for (ll i = L; i <= min(N * 6, R); i++)
			sum += dp[i];
		printf("%.10f\n", sum);
	}
	else {
		double mu = N * 3.5, bunsan = N * 35.0/12, sum = 0;
		for (double x = mu - 100000; x <= mu + 100000; x += 0.001)
			if (L <= x && x <= R)
				sum += f(mu, bunsan, x - 0.0005) * 0.001;
		printf("%.10f\n", sum);
	}
}
0