結果

問題 No.813 ユキちゃんの冒険
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 00:41:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 29,892 KB
最終ジャッジ日時 2023-09-10 22:26:22
合計ジャッジ時間 7,378 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 132 ms
29,560 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 141 ms
29,632 KB
testcase_06 AC 134 ms
29,576 KB
testcase_07 AC 130 ms
29,384 KB
testcase_08 AC 138 ms
29,720 KB
testcase_09 AC 129 ms
29,500 KB
testcase_10 AC 133 ms
29,512 KB
testcase_11 AC 132 ms
29,344 KB
testcase_12 AC 138 ms
29,608 KB
testcase_13 AC 135 ms
29,588 KB
testcase_14 AC 129 ms
29,480 KB
testcase_15 AC 139 ms
29,484 KB
testcase_16 AC 141 ms
29,516 KB
testcase_17 AC 130 ms
29,520 KB
testcase_18 AC 128 ms
29,492 KB
testcase_19 AC 140 ms
29,584 KB
testcase_20 AC 132 ms
29,380 KB
testcase_21 AC 131 ms
29,488 KB
testcase_22 AC 130 ms
29,396 KB
testcase_23 AC 142 ms
29,424 KB
testcase_24 WA -
testcase_25 AC 140 ms
29,892 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 p==1:
    x = 1
elif q==0:
    x = p
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