結果

問題 No.1501 酔歩
ユーザー tamatotamato
提出日時 2021-05-07 23:18:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 885 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 87,408 KB
実行使用メモリ 91,636 KB
最終ジャッジ日時 2023-10-13 14:37:59
合計ジャッジ時間 8,841 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,804 KB
testcase_01 AC 64 ms
71,708 KB
testcase_02 AC 64 ms
71,776 KB
testcase_03 AC 66 ms
71,932 KB
testcase_04 AC 67 ms
71,888 KB
testcase_05 AC 147 ms
87,932 KB
testcase_06 AC 131 ms
84,776 KB
testcase_07 AC 146 ms
87,792 KB
testcase_08 AC 82 ms
77,256 KB
testcase_09 AC 142 ms
86,336 KB
testcase_10 AC 100 ms
79,904 KB
testcase_11 AC 140 ms
84,948 KB
testcase_12 AC 93 ms
81,720 KB
testcase_13 AC 66 ms
71,624 KB
testcase_14 AC 67 ms
71,656 KB
testcase_15 AC 66 ms
71,512 KB
testcase_16 AC 66 ms
71,592 KB
testcase_17 AC 65 ms
71,664 KB
testcase_18 AC 64 ms
71,748 KB
testcase_19 AC 65 ms
71,600 KB
testcase_20 AC 66 ms
71,600 KB
testcase_21 AC 65 ms
71,660 KB
testcase_22 AC 160 ms
91,140 KB
testcase_23 AC 171 ms
91,008 KB
testcase_24 AC 166 ms
91,140 KB
testcase_25 AC 147 ms
91,264 KB
testcase_26 AC 134 ms
91,200 KB
testcase_27 AC 159 ms
91,636 KB
testcase_28 AC 185 ms
91,284 KB
testcase_29 AC 135 ms
91,156 KB
testcase_30 AC 169 ms
91,160 KB
testcase_31 AC 133 ms
91,184 KB
testcase_32 AC 144 ms
91,068 KB
testcase_33 AC 179 ms
91,392 KB
testcase_34 AC 172 ms
91,156 KB
testcase_35 AC 163 ms
91,440 KB
testcase_36 AC 185 ms
91,164 KB
testcase_37 AC 128 ms
91,088 KB
testcase_38 AC 138 ms
91,256 KB
testcase_39 AC 186 ms
91,384 KB
testcase_40 AC 145 ms
91,056 KB
testcase_41 AC 176 ms
91,232 KB
testcase_42 AC 105 ms
90,720 KB
testcase_43 AC 67 ms
71,760 KB
testcase_44 AC 67 ms
71,756 KB
testcase_45 AC 113 ms
90,716 KB
testcase_46 AC 116 ms
90,884 KB
testcase_47 AC 105 ms
90,840 KB
testcase_48 AC 106 ms
90,892 KB
testcase_49 AC 117 ms
90,768 KB
testcase_50 AC 107 ms
90,772 KB
testcase_51 AC 112 ms
90,924 KB
testcase_52 AC 107 ms
90,772 KB
testcase_53 AC 64 ms
71,752 KB
testcase_54 AC 66 ms
71,420 KB
testcase_55 AC 75 ms
71,600 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")
        exit()

    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