結果
問題 | No.751 Frac #2 |
ユーザー |
![]() |
提出日時 | 2022-11-19 01:30:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 476 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-09-20 05:33:06 |
合計ジャッジ時間 | 2,524 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 33 WA * 3 |
ソースコード
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 a[0] y = Fraction(reduce(mul, b[1::2]), reduce(mul, b[0::2])) if n2 > 1 else b[0] ans = Fraction(x * y) print(ans.numerator, ans.denominator) if __name__ == "__main__": main()