結果

問題 No.813 ユキちゃんの冒険
ユーザー rookzenorookzeno
提出日時 2019-04-12 23:11:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 92,164 KB
最終ジャッジ日時 2023-08-30 13:34:21
合計ジャッジ時間 9,747 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,584 KB
testcase_01 AC 121 ms
77,760 KB
testcase_02 AC 206 ms
78,320 KB
testcase_03 AC 182 ms
78,120 KB
testcase_04 AC 98 ms
71,304 KB
testcase_05 AC 762 ms
89,592 KB
testcase_06 AC 259 ms
78,916 KB
testcase_07 AC 129 ms
77,852 KB
testcase_08 AC 684 ms
82,892 KB
testcase_09 AC 122 ms
77,644 KB
testcase_10 AC 214 ms
78,356 KB
testcase_11 AC 167 ms
78,092 KB
testcase_12 AC 509 ms
82,736 KB
testcase_13 AC 280 ms
79,336 KB
testcase_14 WA -
testcase_15 AC 1,177 ms
86,588 KB
testcase_16 AC 679 ms
88,140 KB
testcase_17 AC 136 ms
77,900 KB
testcase_18 AC 119 ms
77,524 KB
testcase_19 AC 868 ms
92,164 KB
testcase_20 AC 186 ms
78,056 KB
testcase_21 AC 131 ms
77,884 KB
testcase_22 AC 136 ms
78,012 KB
testcase_23 AC 507 ms
79,652 KB
testcase_24 AC 96 ms
71,512 KB
testcase_25 AC 96 ms
71,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
p = float(input())
q = float(input())
dp = [[0,0]for i in range(n+2)]
dp[1][0] = 1
if p + q == 1:
    print(1-q**n)
    exit()
for i in range(6*n*2):
    dp2 = [[0,0]for i in range(n+2)]
    for j in range(n,0,-1):
        dp2[j+1][0] += dp[j][0]*q
        dp2[j-1][1] += dp[j][1]*q
        dp2[j-1][1] += dp[j][0]*p
        dp2[j+1][0] += dp[j][1]*p
    dp2[0][0] += dp[0][0]
    dp2[0][1] += dp[0][1]
    dp = dp2
print(sum(dp[0]))
0