結果
| 問題 | No.751 Frac #2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-26 10:59:28 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,260 bytes |
| 記録 | |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 15,232 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2026-09-24 01:42:25 |
| 合計ジャッジ時間 | 3,776 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 WA * 16 |
ソースコード
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()))
if n%2 == 0:
child = a[0]
mother = 1
for i in range(1,n):
mother *= a[i]
for i in range(m):
if m%2 == 0:
child *= b[i]
else:
mother *= 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)
else:
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()