結果

問題 No.1501 酔歩
ユーザー mkawa2mkawa2
提出日時 2024-01-25 18:28:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 1,205 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 126,944 KB
最終ジャッジ日時 2024-01-25 18:28:53
合計ジャッジ時間 20,901 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
87,696 KB
testcase_01 AC 132 ms
87,696 KB
testcase_02 AC 132 ms
87,696 KB
testcase_03 AC 132 ms
87,696 KB
testcase_04 AC 131 ms
87,568 KB
testcase_05 AC 428 ms
118,832 KB
testcase_06 AC 344 ms
111,432 KB
testcase_07 AC 380 ms
116,768 KB
testcase_08 AC 268 ms
95,632 KB
testcase_09 AC 356 ms
113,568 KB
testcase_10 AC 262 ms
98,192 KB
testcase_11 AC 341 ms
111,020 KB
testcase_12 AC 332 ms
104,592 KB
testcase_13 AC 131 ms
87,568 KB
testcase_14 AC 132 ms
87,568 KB
testcase_15 AC 131 ms
87,568 KB
testcase_16 AC 132 ms
87,568 KB
testcase_17 AC 132 ms
87,568 KB
testcase_18 AC 129 ms
87,568 KB
testcase_19 AC 132 ms
87,568 KB
testcase_20 AC 131 ms
87,568 KB
testcase_21 AC 130 ms
87,568 KB
testcase_22 AC 444 ms
126,264 KB
testcase_23 AC 465 ms
126,268 KB
testcase_24 AC 436 ms
126,780 KB
testcase_25 AC 435 ms
126,528 KB
testcase_26 AC 463 ms
126,400 KB
testcase_27 AC 438 ms
126,400 KB
testcase_28 AC 434 ms
126,404 KB
testcase_29 AC 443 ms
126,660 KB
testcase_30 AC 436 ms
126,268 KB
testcase_31 AC 472 ms
126,296 KB
testcase_32 AC 449 ms
126,404 KB
testcase_33 AC 440 ms
126,276 KB
testcase_34 AC 440 ms
126,392 KB
testcase_35 AC 440 ms
126,404 KB
testcase_36 AC 455 ms
126,400 KB
testcase_37 AC 440 ms
126,268 KB
testcase_38 AC 442 ms
126,396 KB
testcase_39 AC 467 ms
126,396 KB
testcase_40 AC 437 ms
126,276 KB
testcase_41 AC 446 ms
126,272 KB
testcase_42 AC 351 ms
126,720 KB
testcase_43 AC 131 ms
87,568 KB
testcase_44 AC 131 ms
87,568 KB
testcase_45 AC 347 ms
126,944 KB
testcase_46 AC 375 ms
126,936 KB
testcase_47 AC 352 ms
126,932 KB
testcase_48 AC 386 ms
126,820 KB
testcase_49 AC 411 ms
126,560 KB
testcase_50 AC 392 ms
126,820 KB
testcase_51 AC 407 ms
126,820 KB
testcase_52 AC 410 ms
126,704 KB
testcase_53 AC 131 ms
87,568 KB
testcase_54 AC 133 ms
87,696 KB
testcase_55 AC 132 ms
87,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from fractions import Fraction

n,k=LI()
aa=LI()

if n==1:
    print("1/1")
    exit()

bb=[Fraction() for _ in range(n)]
cc=[Fraction() for _ in range(n)]
bb[1]+=1

for i in range(2,n):
    f=Fraction(-aa[i-2],aa[i])
    g=Fraction(aa[i-2]+aa[i],aa[i])
    bb[i]=f*bb[i-2]+g*bb[i-1]
    cc[i]=f*cc[i-2]+g*cc[i-1]

x=(1-cc[-1])/bb[-1]
k-=1
ans=bb[k]*x+cc[k]
if ans==0:
    print(0)
else:
    print(ans.numerator,ans.denominator,sep="/")
0