結果

問題 No.813 ユキちゃんの冒険
ユーザー rookzenorookzeno
提出日時 2019-04-12 23:09:41
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 551 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 102,472 KB
最終ジャッジ日時 2023-08-30 13:34:51
合計ジャッジ時間 13,574 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,704 KB
testcase_01 AC 120 ms
77,624 KB
testcase_02 AC 252 ms
78,880 KB
testcase_03 AC 222 ms
78,284 KB
testcase_04 AC 98 ms
71,520 KB
testcase_05 AC 1,291 ms
97,356 KB
testcase_06 AC 341 ms
80,012 KB
testcase_07 AC 134 ms
78,080 KB
testcase_08 AC 1,136 ms
86,372 KB
testcase_09 AC 127 ms
78,172 KB
testcase_10 AC 273 ms
79,156 KB
testcase_11 AC 194 ms
78,300 KB
testcase_12 AC 730 ms
85,944 KB
testcase_13 AC 377 ms
80,544 KB
testcase_14 AC 117 ms
77,624 KB
testcase_15 TLE -
testcase_16 AC 1,043 ms
94,964 KB
testcase_17 AC 147 ms
78,164 KB
testcase_18 AC 124 ms
77,984 KB
testcase_19 AC 1,322 ms
102,472 KB
testcase_20 AC 226 ms
78,424 KB
testcase_21 AC 142 ms
78,116 KB
testcase_22 AC 141 ms
78,156 KB
testcase_23 AC 870 ms
81,312 KB
testcase_24 AC 96 ms
71,568 KB
testcase_25 AC 95 ms
72,040 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(10*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