結果
| 問題 | No.302 サイコロで確率問題 (2) |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2024-08-19 01:31:40 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 3,041 ms / 6,000 ms |
| + 896µs | |
| コード長 | 699 bytes |
| 記録 | |
| コンパイル時間 | 307 ms |
| コンパイル使用メモリ | 21,536 KB |
| 実行使用メモリ | 117,432 KB |
| 最終ジャッジ日時 | 2026-08-25 02:49:16 |
| 合計ジャッジ時間 | 69,679 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from scipy.stats import norm
import numpy as np
N, L, R = map(int, read().split())
def solve_small(N, L, R):
if L > 6 * N:
return 0
R = min(R, 6 * N)
dice = np.array([0, 1, 1, 1, 1, 1, 1], np.float64) / 6
dp = np.ones(1)
for _ in range(N):
dp = np.convolve(dp, dice)
return dp[L: R + 1].sum()
def solve_large(N, L, R):
mu = 3.5 * N
sigma = np.sqrt(35 * N / 12)
ZR = (R + 0.5 - mu) / sigma
ZL = (L - 0.5 - mu) / sigma
return norm.cdf(ZR) - norm.cdf(ZL)
f = solve_small if N <= 5000 else solve_large
print(f(N, L, R))
maspy