結果

問題 No.75 回数の期待値の問題
ユーザー square1001square1001
提出日時 2022-10-09 20:57:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,379 ms / 5,000 ms
コード長 328 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 7,904 KB
最終ジャッジ日時 2023-09-05 23:56:35
合計ジャッジ時間 8,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,788 KB
testcase_01 AC 17 ms
7,792 KB
testcase_02 AC 18 ms
7,816 KB
testcase_03 AC 21 ms
7,852 KB
testcase_04 AC 18 ms
7,904 KB
testcase_05 AC 18 ms
7,820 KB
testcase_06 AC 19 ms
7,864 KB
testcase_07 AC 22 ms
7,820 KB
testcase_08 AC 23 ms
7,792 KB
testcase_09 AC 25 ms
7,788 KB
testcase_10 AC 26 ms
7,840 KB
testcase_11 AC 31 ms
7,788 KB
testcase_12 AC 31 ms
7,868 KB
testcase_13 AC 34 ms
7,852 KB
testcase_14 AC 35 ms
7,792 KB
testcase_15 AC 46 ms
7,812 KB
testcase_16 AC 446 ms
7,812 KB
testcase_17 AC 1,428 ms
7,820 KB
testcase_18 AC 2,074 ms
7,772 KB
testcase_19 AC 2,379 ms
7,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

dp = [ 0.0 ] * (n + 6)
dp[0] = 1.0

answer = 0
iters = 0
while sum(dp) > 1.0e-20:
	ndp = [ 0.0 ] * (n + 6)
	for i in range(n):
		for j in range(1, 7):
			ndp[i + j] += dp[i] / 6
	for i in range(n + 1, n + 6):
		ndp[0] += ndp[i]
		ndp[i] = 0
	dp = ndp.copy()
	iters += 1
	answer += ndp[n] * iters

print(answer)
0