結果

問題 No.1501 酔歩
ユーザー tamatotamato
提出日時 2021-05-07 23:17:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 91,360 KB
最終ジャッジ日時 2023-10-13 14:36:56
合計ジャッジ時間 9,231 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,816 KB
testcase_01 AC 65 ms
71,560 KB
testcase_02 AC 66 ms
71,464 KB
testcase_03 AC 64 ms
71,492 KB
testcase_04 WA -
testcase_05 AC 157 ms
87,852 KB
testcase_06 AC 135 ms
84,860 KB
testcase_07 AC 148 ms
87,904 KB
testcase_08 AC 88 ms
77,444 KB
testcase_09 AC 149 ms
86,040 KB
testcase_10 AC 100 ms
79,504 KB
testcase_11 AC 136 ms
85,124 KB
testcase_12 AC 95 ms
81,672 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 157 ms
90,948 KB
testcase_23 AC 173 ms
91,180 KB
testcase_24 AC 156 ms
91,184 KB
testcase_25 AC 150 ms
91,168 KB
testcase_26 AC 129 ms
91,320 KB
testcase_27 AC 150 ms
91,360 KB
testcase_28 AC 175 ms
91,092 KB
testcase_29 AC 131 ms
91,216 KB
testcase_30 AC 161 ms
91,140 KB
testcase_31 AC 138 ms
91,208 KB
testcase_32 AC 143 ms
91,096 KB
testcase_33 AC 173 ms
91,072 KB
testcase_34 AC 161 ms
91,184 KB
testcase_35 AC 145 ms
90,920 KB
testcase_36 AC 160 ms
91,188 KB
testcase_37 AC 127 ms
91,012 KB
testcase_38 AC 142 ms
91,156 KB
testcase_39 AC 179 ms
91,240 KB
testcase_40 AC 140 ms
91,048 KB
testcase_41 AC 166 ms
90,952 KB
testcase_42 AC 100 ms
91,080 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 108 ms
90,808 KB
testcase_46 AC 111 ms
90,716 KB
testcase_47 AC 100 ms
90,676 KB
testcase_48 AC 109 ms
90,812 KB
testcase_49 AC 115 ms
90,668 KB
testcase_50 AC 106 ms
90,776 KB
testcase_51 AC 109 ms
90,760 KB
testcase_52 AC 104 ms
90,712 KB
testcase_53 WA -
testcase_54 AC 64 ms
71,640 KB
testcase_55 AC 70 ms
71,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import gcd
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    if N == 1:
        print("1/1")

    if K == 1:
        print(0)
        exit()

    if K == N:
        print("1/1")
        exit()

    upper = [0] * N
    lower = [1] * N
    for i in range(1, N-1):
        a = A[i-1]
        b = A[i+1]
        upper[i] = lower[i-1] * b
        lower[i] = lower[i-1] * (a+b) - a * upper[i-1]
        g = gcd(upper[i], lower[i])
        upper[i] //= g
        lower[i] //= g

    u = l = 1
    for i in range(K-1, N-1):
        u *= upper[i]
        l *= lower[i]
        g = gcd(u, l)
        u //= g
        l //= g
    if u == 0:
        print(0)
    else:
        print(str(u) + "/" + str(l))


if __name__ == '__main__':
    main()
0