結果

問題 No.751 Frac #2
ユーザー NoaSaber
提出日時 2021-04-03 17:49:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 1,172 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 54,244 KB
最終ジャッジ日時 2024-12-25 03:57:05
合計ジャッジ時間 3,759 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 4 WA * 32
権限があれば一括ダウンロードができます

ソースコード

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
print(upA//math.gcd(upA,upB)*-1 if minus%2==1 else 1,upB//math.gcd(upA,upB))
0