結果

問題 No.751 Frac #2
ユーザー はむ吉🐹はむ吉🐹
提出日時 2018-11-09 21:51:05
言語 Python3
(3.11.2 + numpy 1.24.2 + scipy 1.10.1)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 644 bytes
コンパイル時間 65 ms
実行使用メモリ 9,128 KB
最終ジャッジ日時 2022-12-26 19:55:49
合計ジャッジ時間 2,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,092 KB
testcase_01 AC 27 ms
8,844 KB
testcase_02 AC 28 ms
8,972 KB
testcase_03 AC 28 ms
8,888 KB
testcase_04 AC 28 ms
9,052 KB
testcase_05 AC 28 ms
8,896 KB
testcase_06 AC 27 ms
8,884 KB
testcase_07 AC 28 ms
9,128 KB
testcase_08 AC 28 ms
8,912 KB
testcase_09 AC 27 ms
9,048 KB
testcase_10 AC 28 ms
8,848 KB
testcase_11 AC 27 ms
8,976 KB
testcase_12 AC 27 ms
9,004 KB
testcase_13 AC 27 ms
9,084 KB
testcase_14 AC 27 ms
8,880 KB
testcase_15 AC 27 ms
8,908 KB
testcase_16 AC 28 ms
9,040 KB
testcase_17 AC 27 ms
9,052 KB
testcase_18 AC 28 ms
8,840 KB
testcase_19 AC 27 ms
9,052 KB
testcase_20 AC 28 ms
8,972 KB
testcase_21 AC 28 ms
9,100 KB
testcase_22 AC 29 ms
9,104 KB
testcase_23 AC 28 ms
8,888 KB
testcase_24 AC 27 ms
8,876 KB
testcase_25 AC 28 ms
8,896 KB
testcase_26 AC 28 ms
8,896 KB
testcase_27 AC 28 ms
8,880 KB
testcase_28 AC 27 ms
8,900 KB
testcase_29 AC 27 ms
9,084 KB
testcase_30 AC 28 ms
8,884 KB
testcase_31 AC 27 ms
8,884 KB
testcase_32 AC 28 ms
8,932 KB
testcase_33 AC 28 ms
8,896 KB
testcase_34 AC 28 ms
9,052 KB
testcase_35 AC 28 ms
9,104 KB
testcase_36 AC 28 ms
8,904 KB
testcase_37 AC 28 ms
9,000 KB
権限があれば一括ダウンロードができます

ソースコード

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], 1)
    g_lower = functools.reduce(lambda f1, f2: f1 * f2, ys[1::2], 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