結果

問題 No.301 サイコロで確率問題 (1)
ユーザー titiatitia
提出日時 2022-11-03 01:03:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 737 ms / 1,000 ms
コード長 741 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 8,548 KB
最終ジャッジ日時 2023-09-24 11:43:43
合計ジャッジ時間 2,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 737 ms
8,548 KB
testcase_01 AC 39 ms
7,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def solve(x):
    OK=0
    NG=1<<60

    while NG>OK+10**(-13):
        mid=(OK+NG)/2

        DP=[0]*x

        for i in range(x-1,-1,-1):
            score=6
            
            for j in range(1,7):
                if i+j==x:
                    score+=0
                elif i+j>x:
                    score+=mid
                else:
                    score+=DP[i+j]

            if i!=0:
                DP[i]=score/6
            else:
                if score/6>mid:
                    OK=mid
                else:
                    NG=mid

    return OK

t=int(input())
for tests in range(t):
    N=int(input())

    if N<=130:
        print(solve(N))
    else:
        print(N+5/3)


0