結果

問題 No.75 回数の期待値の問題
ユーザー しらっ亭しらっ亭
提出日時 2015-09-14 02:16:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-26 11:48:36
合計ジャッジ時間 1,526 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 17 ms
7,788 KB
testcase_02 AC 17 ms
7,768 KB
testcase_03 AC 17 ms
7,792 KB
testcase_04 AC 17 ms
7,776 KB
testcase_05 AC 17 ms
7,848 KB
testcase_06 AC 17 ms
7,780 KB
testcase_07 AC 17 ms
7,800 KB
testcase_08 AC 16 ms
7,836 KB
testcase_09 AC 18 ms
7,800 KB
testcase_10 AC 18 ms
7,888 KB
testcase_11 AC 17 ms
7,792 KB
testcase_12 AC 17 ms
7,804 KB
testcase_13 AC 18 ms
7,888 KB
testcase_14 AC 18 ms
7,852 KB
testcase_15 AC 19 ms
7,948 KB
testcase_16 AC 25 ms
7,800 KB
testcase_17 AC 32 ms
7,780 KB
testcase_18 AC 34 ms
7,836 KB
testcase_19 AC 36 ms
7,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    K = int(input())

    a = 0
    b = K * 100
    for i in range(100):
        c = (a + b) / 2

        dp = [0] * (K + 1)
        dp[0] = 0
        for i in range(1, K + 1):
            for j in range(1, 7):
                if i - j < 0:
                    dp[i] += c
                elif i - j > 0:
                    dp[i] += dp[i - j]
            dp[i] /= 6
            dp[i] += 1

        if dp[K] > c:
            a = c
        else:
            b = c

    print('{:.5f}'.format(b))


if __name__ == '__main__':
    solve()
0