結果

問題 No.1501 酔歩
ユーザー convexineqconvexineq
提出日時 2021-05-08 03:18:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 532 ms / 2,000 ms
コード長 285 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 115,200 KB
最終ジャッジ日時 2024-09-15 19:39:38
合計ジャッジ時間 21,805 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction as F
n,k,*a = map(int,open(0).read().split())
a = [0]+[F(a[i-1],a[i-1]+a[i+1]) for i in range(1,n-1)]
r = [F(n==1),F(1)]
for i in range(1,n-1):
    r.append((r[-1]-r[-2]*a[i])/(1-a[i]))
A = r[k-1]/r[-1]
print(f"{A.numerator}/{A.denominator}" if A else 0)
0