結果

問題 No.1931 Fraction 2
ユーザー gew1fw
提出日時 2025-06-12 15:59:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 355 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 89,700 KB
最終ジャッジ日時 2025-06-12 15:59:26
合計ジャッジ時間 5,662 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

MOD = 998244353

n = int(input())
current_num = 0
current_den = 1

for _ in range(n):
    a, b = map(int, input().split())
    new_num = current_num * b + a * current_den
    new_den = current_den * b
    g = math.gcd(new_num, new_den)
    current_num = new_num // g
    current_den = new_den // g

print(current_num % MOD, current_den % MOD)
0