結果

問題 No.751 Frac #2
ユーザー はむ吉🐹
提出日時 2018-11-09 21:50:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 660 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-11-21 05:50:48
合計ジャッジ時間 2,453 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 2
other RE * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import fractions
import functools


def main():
    _ = input()
    xs = [fractions.Fraction(int(x), 1) for x in input().split()]
    f = functools.reduce(lambda f1, f2: f1 / f2, xs)
    # print(f)
    _ = input()
    ys = [fractions.Fraction(int(x), 1) for x in input().split()]
    g_upper = functools.reduce(lambda f1, f2: f1 * f2, ys[::2], initial=1)
    g_lower = functools.reduce(lambda f1, f2: f1 * f2, ys[1::2], initial=1)
    g = g_upper / g_lower
    # print(g)
    res = f / g
    if res.denominator >= 0:
        print(res.numerator, res.denominator)
    else:
        print(-res.numerator, -res.denominator)


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