結果

問題 No.751 Frac #2
ユーザー chocorusk
提出日時 2018-11-10 08:36:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 460 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-22 10:19:48
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

n1=int(input())
a=list(map(int, input().split()))
a1=abs(a[0])
a2=1
p=a[0]//abs(a[0])
for i in range(1, n1):
    a2*=abs(a[i])
    p*=(a[i]//abs(a[i]))
n2=int(input())
b1=1
b2=1
b=list(map(int, input().split()))
for i in range(n2):
    if i%2:
        b2*=abs(b[i])
    else:
        b1*=abs(b[i])
    p*=(b[i]//abs(b[i]))
c1=a1*b2
c2=a2*b1
def gcd(x, y):
    if y==0:
        return x
    return gcd(y, x%y)
g=gcd(c1, c2)
print("{} {}".format(c1//g*p, c2//g))
0