結果

問題 No.813 ユキちゃんの冒険
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 00:40:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 30,088 KB
最終ジャッジ日時 2023-09-10 22:24:45
合計ジャッジ時間 8,012 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 143 ms
29,716 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 150 ms
29,916 KB
testcase_06 AC 143 ms
29,880 KB
testcase_07 AC 136 ms
29,768 KB
testcase_08 AC 145 ms
29,936 KB
testcase_09 AC 138 ms
29,596 KB
testcase_10 AC 143 ms
29,672 KB
testcase_11 AC 142 ms
29,736 KB
testcase_12 AC 147 ms
29,852 KB
testcase_13 AC 144 ms
29,848 KB
testcase_14 AC 141 ms
29,708 KB
testcase_15 AC 152 ms
29,820 KB
testcase_16 AC 152 ms
29,884 KB
testcase_17 AC 142 ms
29,720 KB
testcase_18 AC 138 ms
29,712 KB
testcase_19 AC 149 ms
30,032 KB
testcase_20 AC 142 ms
29,704 KB
testcase_21 AC 140 ms
29,636 KB
testcase_22 AC 140 ms
29,608 KB
testcase_23 AC 147 ms
29,824 KB
testcase_24 WA -
testcase_25 AC 157 ms
30,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

import numpy as np
n = int(input())
p = float(input())
q = float(input())
if q==0:
    x = 1
else:
    dp0 = [0]*n
    dp1 = [0]*n
    dp0[0] = np.array((1,0), dtype=np.float64)
    dp1[0] = np.array((0,1), dtype=np.float64)
    for i in range(1,n):
        dp0[i] = (dp0[i-1]- p*dp1[i-1]) / q
        dp1[i] = q*dp1[i-1] + p*dp0[i]
        v = np.linalg.norm(dp0[i])
        dp0[i], dp1[i] = dp0[i]/v, dp1[i]/v
    a0,b0 = dp0[n-1]
    a1,b1 = dp1[n-1]
    x = (b1-b0) / (a0-a1)
print(x)
0