結果

問題 No.1501 酔歩
ユーザー そすうぽよそすうぽよ
提出日時 2021-05-07 22:48:27
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 139,380 KB
最終ジャッジ日時 2023-10-13 14:07:11
合計ジャッジ時間 26,099 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
89,012 KB
testcase_01 AC 201 ms
89,076 KB
testcase_02 AC 201 ms
89,028 KB
testcase_03 AC 192 ms
89,080 KB
testcase_04 AC 194 ms
88,960 KB
testcase_05 AC 501 ms
128,852 KB
testcase_06 AC 450 ms
119,548 KB
testcase_07 AC 482 ms
126,308 KB
testcase_08 AC 308 ms
96,840 KB
testcase_09 AC 468 ms
122,708 KB
testcase_10 AC 333 ms
100,552 KB
testcase_11 AC 450 ms
117,916 KB
testcase_12 AC 408 ms
110,228 KB
testcase_13 AC 192 ms
89,104 KB
testcase_14 AC 198 ms
89,124 KB
testcase_15 AC 201 ms
88,968 KB
testcase_16 AC 192 ms
89,088 KB
testcase_17 AC 191 ms
89,160 KB
testcase_18 AC 194 ms
89,036 KB
testcase_19 AC 208 ms
89,180 KB
testcase_20 AC 206 ms
89,060 KB
testcase_21 AC 210 ms
88,832 KB
testcase_22 AC 583 ms
139,084 KB
testcase_23 AC 560 ms
138,952 KB
testcase_24 AC 568 ms
139,120 KB
testcase_25 AC 583 ms
139,136 KB
testcase_26 AC 568 ms
139,116 KB
testcase_27 AC 577 ms
139,108 KB
testcase_28 AC 584 ms
138,900 KB
testcase_29 AC 572 ms
139,380 KB
testcase_30 AC 564 ms
138,944 KB
testcase_31 AC 563 ms
139,120 KB
testcase_32 AC 589 ms
138,972 KB
testcase_33 AC 571 ms
139,308 KB
testcase_34 AC 560 ms
138,976 KB
testcase_35 AC 560 ms
139,084 KB
testcase_36 AC 561 ms
138,736 KB
testcase_37 AC 583 ms
139,004 KB
testcase_38 AC 576 ms
139,120 KB
testcase_39 AC 563 ms
138,868 KB
testcase_40 AC 557 ms
138,992 KB
testcase_41 AC 589 ms
139,108 KB
testcase_42 AC 519 ms
139,308 KB
testcase_43 AC 191 ms
88,968 KB
testcase_44 AC 192 ms
88,928 KB
testcase_45 AC 486 ms
139,092 KB
testcase_46 AC 494 ms
138,980 KB
testcase_47 AC 504 ms
139,020 KB
testcase_48 AC 506 ms
139,048 KB
testcase_49 AC 512 ms
139,232 KB
testcase_50 AC 530 ms
139,304 KB
testcase_51 AC 532 ms
138,948 KB
testcase_52 AC 506 ms
139,248 KB
testcase_53 AC 204 ms
88,904 KB
testcase_54 AC 198 ms
89,104 KB
testcase_55 AC 202 ms
89,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
n,k = map(int, input().split())
a = list(map(int, input().split()))
x1 = [Fraction(0, 1)]
x0 = [Fraction(0, 1)]
for i in range(1, n-1):
    y = Fraction(a[i-1], a[i-1] + a[i+1])
    z = Fraction(a[i+1], a[i-1] + a[i+1])
    nxd = Fraction(1) - y * x1[-1]
    x1.append(z / nxd)
    x0.append(y * x0[-1] / nxd)

p = [Fraction(0) for _i in range(n)]
p[-1] = 1

for ri in range(1, n-1):
    i = n - 1 - ri
    p[i] = x1[i] * p[i+1] + x0[i]

if p[k-1] == 1:
    print("1/1")
else:
    print(p[k-1])
0