結果

問題 No.1501 酔歩
ユーザー suisensuisen
提出日時 2021-05-07 22:50:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 119,376 KB
最終ジャッジ日時 2023-10-13 14:09:35
合計ジャッジ時間 32,946 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 194 ms
89,472 KB
testcase_01 AC 203 ms
89,448 KB
testcase_02 AC 196 ms
89,316 KB
testcase_03 AC 200 ms
89,176 KB
testcase_04 AC 195 ms
89,180 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 202 ms
89,312 KB
testcase_14 AC 205 ms
89,252 KB
testcase_15 AC 202 ms
89,256 KB
testcase_16 AC 201 ms
89,456 KB
testcase_17 AC 199 ms
89,248 KB
testcase_18 AC 200 ms
89,424 KB
testcase_19 AC 197 ms
89,180 KB
testcase_20 AC 195 ms
89,248 KB
testcase_21 AC 194 ms
89,388 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 450 ms
115,784 KB
testcase_43 AC 204 ms
89,444 KB
testcase_44 AC 213 ms
89,284 KB
testcase_45 AC 438 ms
115,948 KB
testcase_46 AC 440 ms
116,076 KB
testcase_47 AC 441 ms
115,888 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 203 ms
89,444 KB
testcase_54 AC 202 ms
89,404 KB
testcase_55 AC 202 ms
89,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
def solve():
    if K == N:
        print('1/1')
        return
    elif K == 1:
        print('0')
        return
    P = [Fraction(0) if i == 0 else Fraction(A[i + 1], A[i - 1] + A[i + 1]) for i in range(N - 1)]
    p2 = Fraction(1)
    p1 = Fraction(1) / P[1]
    for i in range(2, N - 1):
        p2, p1 = p1, (p1 - (1 - P[i]) * p2) / P[i]
    ans = [0] * N
    ans[0] = 0
    ans[1] = 1 / p1
    for i in range(2, N - 1):
        ans[i] = (ans[i - 1] - (1 - P[i]) * ans[i - 2]) / P[i]
    print(ans[K - 1])

solve()
0