結果
| 問題 | No.302 サイコロで確率問題 (2) |
| コンテスト | |
| ユーザー |
sugim48
|
| 提出日時 | 2015-11-13 23:05:37 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,353 bytes |
| 記録 | |
| コンパイル時間 | 925 ms |
| コンパイル使用メモリ | 82,940 KB |
| 実行使用メモリ | 14,016 KB |
| 最終ジャッジ日時 | 2024-09-13 15:05:33 |
| 合計ジャッジ時間 | 13,543 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 3 TLE * 1 -- * 12 |
ソースコード
#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);
}
}
sugim48