結果
| 問題 | No.76 回数の期待値で練習 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-08-26 23:43:47 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,561 ms / 5,000 ms |
| + 414µs | |
| コード長 | 422 bytes |
| 記録 | |
| コンパイル時間 | 62 ms |
| コンパイル使用メモリ | 14,592 KB |
| 実行使用メモリ | 184,448 KB |
| 最終ジャッジ日時 | 2026-10-16 02:07:44 |
| 合計ジャッジ時間 | 2,760 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
from functools import cache
import sys
sys.setrecursionlimit(10 ** 6 + 100)
probs = [0, 1/12, 2/12, 3/12, 1/12, 3/12, 2/12]
memo = {}
def f(x: int) -> float:
if x <= 0: return 0
if x in memo: return memo[x]
res = 0
for i in range(1, 7):
res += (f(x - i) + 1) * probs[i]
memo[x] = res
return res
T = int(input())
for _ in range(T):
N = int(input())
ans = f(N)
print(ans)
norioc