結果
| 問題 | 
                            No.751 Frac #2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             brthyyjp
                         | 
                    
| 提出日時 | 2021-12-17 19:55:55 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 42 ms / 1,000 ms | 
| コード長 | 410 bytes | 
| コンパイル時間 | 459 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 52,352 KB | 
| 最終ジャッジ日時 | 2024-09-14 21:17:36 | 
| 合計ジャッジ時間 | 2,983 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 36 | 
ソースコード
n1 = int(input())
A = list(map(int, input().split()))
n2 = int(input())
B = list(map(int, input().split()))
x = A[0]
y = 1
for i in range(1, n1):
    y *= A[i]
for i in range(n2):
    if i%2 == 0:
        y *= B[i]
    else:
        x *= B[i]
import math
if x*y > 0:
    g = math.gcd(x, y)
    a, b = abs(x)//g, abs(y)//g
else:
    g = math.gcd(abs(x), abs(y))
    a, b = -abs(x)//g, abs(y)//g
print(a, b)
            
            
            
        
            
brthyyjp