結果

問題 No.751 Frac #2
コンテスト
ユーザー 学ぶマン
提出日時 2025-11-21 17:26:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 82,692 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2025-11-21 17:26:36
合計ジャッジ時間 3,378 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
N1 = int(input())
A = list(map(int, input().split()))
N2 = int(input())
B = list(map(int, input().split()))

sign = 1
for a in A:
    if a < 0:
        sign *= -1

for b in B:
    if b < 0:
        sign *= -1

bunshi, bumbo = abs(A[0]), 1

# A
for i in range(1, N1):
    bumbo *= abs(A[i])

# B
for i in range(N2):
    if i%2 == 0:
        bumbo *= abs(B[i])
    else:
        bunshi *= abs(B[i])

g = math.gcd(bumbo, bunshi)
bumbo //= g
bunshi //= g

bunshi *= sign
print(bunshi, bumbo)
0