結果
| 問題 |
No.302 サイコロで確率問題 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-13 23:19:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 925 bytes |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 54,656 KB |
| 最終ジャッジ日時 | 2024-09-13 15:14:15 |
| 合計ジャッジ時間 | 1,762 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 2 |
ソースコード
import collections
import math
def solve(N, L, R):
if N < 300:
return solve_exact(N, L, R)
else:
return solve_approximate(N, L, R)
def solve_exact(N, L, R):
fs = {0: 1.0}
for n in range(N-1, -1, -1):
nfs = collections.defaultdict(float)
for v, p in fs.items():
for dice in range(1, 7):
nv = v + dice
if nv + n <= R and nv + n * 6 >= L:
nfs[nv] += p * 1/6
fs = nfs
cum = 0.0
for v, p in fs.items():
if L <= v and v <= R:
cum += p
return cum
def solve_approximate(N, L, R):
E = N * 3.5
Var = N * 35.0/12.0
r = (R + 0.5 - E)/math.sqrt(Var)
l = (L - 0.5 - E)/math.sqrt(Var)
return phi(r) - phi(l)
def phi(x):
return (1.0 + math.erf(x / math.sqrt(2.0))) / 2.0
N = int(input())
L, R = map(int, input().split())
print(solve(N, L, R))