結果

問題 No.751 Frac #2
ユーザー NoaSaber
提出日時 2021-04-03 17:50:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 52,608 KB
最終ジャッジ日時 2024-12-25 04:01:25
合計ジャッジ時間 3,559 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

n_1=int(input())
A=list(map(int,input().split()))
n_2=int(input())
B=list(map(int,input().split()))
minus=0
import math
upA,upB=A[0],B[0]
if upA<0:
    minus+=1
    upA=abs(upA)
if upB<0:
    minus+=1
    upB=abs(upB)
downA,downB=A[1:],B[1:]
def A(l): 
    global minus  
    tmp=1
    for i in l:
        if i<0:
            i=abs(i)
            minus+=1
        tmp*=i
    return tmp
downA=A(downA)
downB=A(downB)
gcd_all=downA*downB//math.gcd(downA,downB)
downA=gcd_all//downA
downB=gcd_all//downB
upA*=downA;upB*=downB
s=-1 if minus%2==1 else 1
print(s*upA//math.gcd(upA,upB),upB//math.gcd(upA,upB))
0