結果

問題 No.751 Frac #2
ユーザー hiragnhiragn
提出日時 2022-11-19 01:29:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-09-20 05:32:23
合計ジャッジ時間 2,411 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
from functools import reduce
from operator import mul


def main():
    n1 = int(input())
    a = list(map(int, input().split()))
    n2 = int(input())
    b = list(map(int, input().split()))

    x = Fraction(a[0], reduce(mul, a[1:])) if n1 > 1 else 1
    y = Fraction(reduce(mul, b[1::2]), reduce(mul, b[0::2])) if n2 > 1 else 1
    ans = Fraction(x * y)
    print(ans.numerator, ans.denominator)


if __name__ == "__main__":
    main()
0