結果

問題 No.751 Frac #2
ユーザー convexineq
提出日時 2021-03-14 17:27:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 279 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 54,076 KB
最終ジャッジ日時 2024-11-06 07:04:32
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())
m = int(input())
*b, = map(int,input().split())

p = a[0]
q = 1
for i in a[1:]:
    q *= i
for i in b[1::2]:
    p *= i
for i in b[::2]:
    q *= i
from math import gcd
g = gcd(p,q)
p //= g; q //= g
if q < 0: p,q = -p,-q
print(p,q)
0