結果

問題 No.75 回数の期待値の問題
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-05 18:43:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 371 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 32,140 KB
最終ジャッジ日時 2023-08-22 10:23:20
合計ジャッジ時間 6,144 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
29,800 KB
testcase_01 AC 130 ms
29,836 KB
testcase_02 AC 130 ms
29,872 KB
testcase_03 AC 131 ms
29,784 KB
testcase_04 AC 133 ms
29,744 KB
testcase_05 AC 132 ms
29,816 KB
testcase_06 AC 130 ms
29,764 KB
testcase_07 AC 133 ms
29,792 KB
testcase_08 AC 134 ms
29,720 KB
testcase_09 AC 129 ms
29,856 KB
testcase_10 AC 133 ms
29,884 KB
testcase_11 AC 132 ms
29,728 KB
testcase_12 AC 130 ms
29,740 KB
testcase_13 AC 132 ms
29,776 KB
testcase_14 AC 132 ms
29,812 KB
testcase_15 AC 129 ms
29,980 KB
testcase_16 AC 151 ms
30,308 KB
testcase_17 AC 135 ms
30,388 KB
testcase_18 AC 134 ms
32,140 KB
testcase_19 AC 133 ms
30,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
K = int(input())
A = np.zeros((K+1, K+1), dtype = np.float64)
for i in range(K + 1):
    A[i, i] = 1.0
    p = 1.0
    for j in range(1, 7):
        if i + j > K:
            break
        A[i, i + j] -= 1.0 / 6.0
        p -= 1.0 / 6.0
    if i < K:
        A[i, 0] -= p

B = np.ones(K+1, np.float64)
B[K] = 0.0

E = np.linalg.solve(A, B)
print(E[0])
0