結果

問題 No.76 回数の期待値で練習
ユーザー yaoshimaxyaoshimax
提出日時 2015-03-01 18:11:52
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,183 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 6,660 KB
実行使用メモリ 61,604 KB
最終ジャッジ日時 2023-09-06 05:52:18
合計ジャッジ時間 7,443 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,091 ms
61,604 KB
testcase_01 AC 2,183 ms
61,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = [0.0 for i in range(7)]
prob = [0.0 for i in range(1000001)]
ans = [0.0,1.0000000000000000,1.0833333333333333,1.2569444444444444,1.5353009259259260,1.6915991512345676,2.0513639724794235]

def calc(N):
    global prob
    for i in xrange(1,N):
        prob[i]=1.0
        for j in xrange(1,7):
            prob[i]+=prob[max(0,(i-j))]*p[j]

for i in range(1,6):
    left = 0.0
    right = 1.0
    for t in range(500):
        mid = (left+right)/2
        p[i]=mid
        p[6]=1
        for j in range(i+1):
            p[6]-=p[j]
        calc(i+2)
        if prob[i+1]>ans[i+1]:
            right=mid
        else:
            left=mid

#for i in range(1,7):
#    print p[i],
#print
calc(1000001)
        
T=int(raw_input())
for i in xrange(T):
    N=int(raw_input())
    print prob[N]

0