結果

問題 No.751 Frac #2
コンテスト
ユーザー ntuda
提出日時 2024-11-22 22:18:12
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 37 ms / 1,000 ms
+ 146µs
コード長 434 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 65,448 KB
実行使用メモリ 54,528 KB
最終ジャッジ日時 2026-10-14 01:00:24
合計ジャッジ時間 4,212 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N1 = int(input())
A = list(map(int,input().split()))
N2 = int(input())
B = list(map(int,input().split()))
daut = 1
mot = 1
for i in range(N1):
    if i == 0:
        daut *= A[i]
    else:
        mot *= A[i]
for i in range(N2):
    if i % 2 == 0:
        mot *= B[i]
    else:
        daut *= B[i]
a = 1
if mot * daut < 0:
    a = -1
mot = abs(mot)
daut = abs(daut)

from math import gcd
x = gcd(mot,daut)
print(daut//x * a,mot//x)

0