結果
| 問題 | No.1501 酔歩 |
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2021-05-07 22:22:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 493 ms / 2,000 ms |
| コード長 | 412 bytes |
| コンパイル時間 | 341 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 117,376 KB |
| 最終ジャッジ日時 | 2024-09-15 10:26:12 |
| 合計ジャッジ時間 | 20,088 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
ソースコード
from fractions import Fraction as F
n,k = map(int,input().split())
*a, = map(int,input().split())
if k==1:
if n==1: print("1/1")
else: print(0)
exit()
a = [F(0)]+[F(a[i-1],a[i-1]+a[i+1]) for i in range(1,n-1)]+[F(0)]
r = [F(0)]*n
r[1] = F(1)
for i in range(2,n):
r[i] = (r[i-1]-r[i-2]*a[i-1])/(F(1)-a[i-1])
# 1 = a+b, r[k-1] = r[-1]b
ans = r[k-1]/r[-1]
print(f"{ans.numerator}/{ans.denominator}")
convexineq