結果

問題 No.66 輝け☆全国たこやき杯
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-22 01:20:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 585 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 8,252 KB
最終ジャッジ日時 2023-09-22 21:09:48
合計ジャッジ時間 1,094 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,864 KB
testcase_01 AC 15 ms
7,808 KB
testcase_02 AC 16 ms
7,772 KB
testcase_03 AC 16 ms
7,728 KB
testcase_04 AC 16 ms
7,872 KB
testcase_05 AC 17 ms
7,816 KB
testcase_06 AC 18 ms
7,720 KB
testcase_07 AC 22 ms
7,820 KB
testcase_08 AC 39 ms
7,768 KB
testcase_09 AC 107 ms
8,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    M = int(input())
    S = [int(input()) ** 2 for i in range(2**M)]
    return M, S

def solve(M, S):
    N = 2**M
    p = [1.0] * N
    for m in range(0, M-1):
        np = [0.0] * N
        for i in range(N):
            pi = p[i]
            Si = S[i]
            start = ((i >> m) ^ 1) << m
            for j in range(start, start + (1 << m)):
                np[i] += pi * p[j] * Si / (Si + S[j])
        p = np
    p0 = p[0]
    S0 = S[0]
    ans = p0 * sum(p[j] * S0 /(S0 + S[j]) for j in range(N//2, N))
    return ans

M, S = read_data()
print(solve(M, S))
0