結果

問題 No.1501 酔歩
ユーザー to-omerto-omer
提出日時 2021-05-07 23:54:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 565 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 55,208 KB
最終ジャッジ日時 2023-10-13 15:16:09
合計ジャッジ時間 32,095 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,860 KB
testcase_01 AC 25 ms
9,760 KB
testcase_02 AC 25 ms
9,600 KB
testcase_03 AC 26 ms
9,760 KB
testcase_04 AC 25 ms
9,744 KB
testcase_05 TLE -
testcase_06 AC 1,546 ms
36,444 KB
testcase_07 AC 1,896 ms
43,184 KB
testcase_08 AC 453 ms
17,108 KB
testcase_09 AC 1,696 ms
39,436 KB
testcase_10 AC 651 ms
21,292 KB
testcase_11 AC 1,485 ms
36,092 KB
testcase_12 AC 1,102 ms
28,440 KB
testcase_13 AC 26 ms
9,852 KB
testcase_14 AC 24 ms
9,648 KB
testcase_15 AC 26 ms
9,636 KB
testcase_16 AC 25 ms
9,688 KB
testcase_17 AC 24 ms
9,828 KB
testcase_18 AC 25 ms
9,748 KB
testcase_19 AC 26 ms
9,704 KB
testcase_20 AC 26 ms
9,648 KB
testcase_21 AC 26 ms
9,864 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 27 ms
9,852 KB
testcase_44 AC 25 ms
9,680 KB
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
testcase_53 AC 26 ms
9,928 KB
testcase_54 AC 27 ms
9,780 KB
testcase_55 AC 26 ms
9,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction as F
N,K=map(int, input().split())
*A,=map(F, input().split())
if K == N:
    print('1/1')
elif K == 1:
    print('0')
else:
    D=[(F(0),F(0))]
    for i in range(1,N-1):
        b = A[i-1]/(A[i-1]+A[i+1])
        a = A[i+1]/(A[i-1]+A[i+1])
        bb, aa = D[-1]
        de = F(1) - b*aa
        nb = b * bb / de
        na = a / de
        D.append((nb, na))
    X = [F(0)] * N
    X[N-1] = F(1)
    for i in range(N-2, 0, -1):
        b, a = D[i]
        X[i] = b + a * X[i+1]
    print(f'{X[K-1].numerator}/{X[K-1].denominator}')
0