結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,952 KB
testcase_01 AC 70 ms
71,684 KB
testcase_02 AC 76 ms
71,740 KB
testcase_03 AC 71 ms
71,676 KB
testcase_04 WA -
testcase_05 AC 182 ms
87,840 KB
testcase_06 AC 144 ms
84,968 KB
testcase_07 AC 164 ms
87,828 KB
testcase_08 AC 96 ms
77,448 KB
testcase_09 AC 161 ms
86,288 KB
testcase_10 AC 112 ms
79,688 KB
testcase_11 AC 149 ms
84,968 KB
testcase_12 AC 105 ms
81,612 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 173 ms
91,288 KB
testcase_23 AC 187 ms
91,316 KB
testcase_24 AC 181 ms
91,096 KB
testcase_25 AC 164 ms
91,316 KB
testcase_26 AC 143 ms
91,168 KB
testcase_27 AC 169 ms
91,208 KB
testcase_28 AC 196 ms
91,472 KB
testcase_29 AC 147 ms
91,472 KB
testcase_30 AC 186 ms
91,080 KB
testcase_31 AC 151 ms
91,260 KB
testcase_32 AC 157 ms
91,112 KB
testcase_33 AC 193 ms
91,440 KB
testcase_34 AC 175 ms
91,228 KB
testcase_35 AC 168 ms
91,148 KB
testcase_36 AC 183 ms
91,068 KB
testcase_37 AC 143 ms
91,108 KB
testcase_38 AC 154 ms
91,284 KB
testcase_39 AC 200 ms
91,456 KB
testcase_40 AC 158 ms
91,260 KB
testcase_41 AC 189 ms
91,232 KB
testcase_42 AC 115 ms
91,100 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 121 ms
90,752 KB
testcase_46 AC 126 ms
90,840 KB
testcase_47 AC 115 ms
90,924 KB
testcase_48 AC 120 ms
90,780 KB
testcase_49 AC 130 ms
90,904 KB
testcase_50 AC 119 ms
90,912 KB
testcase_51 AC 119 ms
90,884 KB
testcase_52 AC 117 ms
91,044 KB
testcase_53 WA -
testcase_54 AC 70 ms
71,724 KB
testcase_55 AC 70 ms
71,684 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 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
    
    for i in range(1, N-1):
        assert upper[i] < lower[i]

    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