結果

問題 No.66 輝け☆全国たこやき杯
ユーザー 👑 rin204rin204
提出日時 2022-09-29 19:18:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 538 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 76,840 KB
最終ジャッジ日時 2023-08-24 05:01:04
合計ジャッジ時間 1,891 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,692 KB
testcase_01 AC 72 ms
71,372 KB
testcase_02 AC 75 ms
71,504 KB
testcase_03 AC 77 ms
71,404 KB
testcase_04 AC 78 ms
71,668 KB
testcase_05 AC 82 ms
76,356 KB
testcase_06 AC 87 ms
76,336 KB
testcase_07 AC 91 ms
76,680 KB
testcase_08 AC 97 ms
76,604 KB
testcase_09 AC 108 ms
76,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

m = int(input())
S = [float(input()) for _ in range(1 << m)]

def P(i, j):
    a = S[i] ** 2
    b = S[j] ** 2
    return a / (a + b)

dp = [1.0] * (1 << m)
for i in range(m):
    ndp = [0.0] * (1 << m)
    x = 0
    d = 1 << i
    while x < (1 << m):
        L = list(range(x, x + d))
        x += d
        R = list(range(x, x + d))
        x += d
        
        for l in L:
            for r in R:
                ndp[l] += dp[l] * dp[r] * P(l, r)
                ndp[r] += dp[l] * dp[r] * P(r, l)
    dp = ndp

print(dp[0])
        
0