結果

問題 No.1931 Fraction 2
ユーザー gew1fw
提出日時 2025-06-12 20:50:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 355 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 87,040 KB
最終ジャッジ日時 2025-06-12 20:55:52
合計ジャッジ時間 5,538 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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