結果
| 問題 | 
                            No.751 Frac #2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-18 19:42:25 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 421 bytes | 
| コンパイル時間 | 197 ms | 
| コンパイル使用メモリ | 82,412 KB | 
| 実行使用メモリ | 54,776 KB | 
| 最終ジャッジ日時 | 2024-11-23 13:28:12 | 
| 合計ジャッジ時間 | 2,972 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 2 | 
| other | AC * 3 WA * 33 | 
ソースコード
from math import gcd
n_1=int(input())
a=list(map(int,input().split()))
n_2=int(input())
b=list(map(int,input().split()))
a_up=a_down=b_up=b_down=1
for i in range(n_1):
    if i==0:
        a_up*=a[i]
    else:
        a_down*=a[i]
for i in range(n_2):
    if i%2==0:
        b_up*=b[i]
    else:
        b_down*=b[i]
ans1=a_up*b_down
ans2=a_down*b_up
d=gcd(ans1,ans2)
if ans1<0:
    ans1,ans2=-ans1,-ans2
print(ans1,ans2)