結果
| 問題 | 
                            No.751 Frac #2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hiragn
                         | 
                    
| 提出日時 | 2022-11-19 01:31:39 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 36 ms / 1,000 ms | 
| コード長 | 489 bytes | 
| コンパイル時間 | 263 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,520 KB | 
| 最終ジャッジ日時 | 2024-09-20 05:34:13 | 
| 合計ジャッジ時間 | 2,755 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 36 | 
ソースコード
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 Fraction(1, b[0])
    ans = Fraction(x * y)
    print(ans.numerator, ans.denominator)
if __name__ == "__main__":
    main()
            
            
            
        
            
hiragn