結果

問題 No.66 輝け☆全国たこやき杯
ユーザー ayaoniayaoni
提出日時 2020-12-17 01:58:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 880 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 75,736 KB
最終ジャッジ日時 2023-10-20 10:26:19
合計ジャッジ時間 1,264 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,484 KB
testcase_01 AC 40 ms
53,484 KB
testcase_02 AC 39 ms
53,484 KB
testcase_03 AC 40 ms
53,484 KB
testcase_04 AC 40 ms
53,484 KB
testcase_05 AC 49 ms
62,336 KB
testcase_06 AC 50 ms
62,348 KB
testcase_07 AC 55 ms
64,444 KB
testcase_08 AC 66 ms
68,548 KB
testcase_09 AC 84 ms
75,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


M = I()
S = [I()**2 for _ in range(1<<M)]

dp = [[0]*(1<<M) for _ in range(M+1)]
# dp[i][j] = 選手jがi回戦まで勝ち残り、且つ勝利する確率

for j in range(1<<M):
    dp[0][j] = 1

for i in range(1,M+1):
    for j in range(1<<M):
        s = ((j>>(i-1))^1)<<i-1
        a = 0
        for k in range(s,s+(1<<i-1)):
            a += dp[i-1][k]*(S[j]/(S[j]+S[k]))
        dp[i][j] = a*dp[i-1][j]

print(dp[-1][0])
0