結果
| 問題 |
No.1501 酔歩
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:25:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 821 bytes |
| コンパイル時間 | 219 ms |
| コンパイル使用メモリ | 82,336 KB |
| 実行使用メモリ | 102,784 KB |
| 最終ジャッジ日時 | 2025-06-12 21:26:24 |
| 合計ジャッジ時間 | 12,759 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 15 |
ソースコード
import sys
from fractions import Fraction
def main():
N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
A = [0] + A # Convert to 1-based indexing
if K == 1:
print(0)
return
if K == N:
print(1)
return
sum_total = Fraction(0, 1)
sum_k = Fraction(0, 1)
for j in range(2, N + 1):
a_prev = A[j-1]
a_curr = A[j]
denom = a_prev * a_curr
term = Fraction(1, denom)
sum_total += term
if j <= K:
sum_k += term
if sum_total == 0:
print(0)
return
prob = sum_k / sum_total
if prob.denominator == 1:
print(prob.numerator)
else:
print(f"{prob.numerator}/{prob.denominator}")
if __name__ == "__main__":
main()
gew1fw