結果
| 問題 |
No.751 Frac #2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-26 11:03:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 1,000 ms |
| コード長 | 697 bytes |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-11-16 04:11:36 |
| 合計ジャッジ時間 | 2,724 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
ソースコード
INF = 10 ** 9
MOD = 10 **9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import gcd
def main():
n = int(input())
a = list(map(int,input().split()))
m = int(input())
b = list(map(int,input().split()))
child = a[0]
mother = 1
for i in range(1,n):
mother *= a[i]
for i in range(m):
if i%2 == 0:
mother *= b[i]
else:
child *= b[i]
if child < 0 and mother < 0:
child *= -1
mother *= -1
elif child > 0 and mother < 0:
child *= -1
mother *= -1
g = gcd(child,mother)
print(child//g,mother//g)
if __name__=='__main__':
main()