結果

問題 No.3020 ユークリッドの互除法・改
コンテスト
ユーザー 👑 rin204
提出日時 2025-02-14 23:45:55
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 32 ms / 2,000 ms
+ 698µs
コード長 202 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 64,596 KB
実行使用メモリ 53,824 KB
最終ジャッジ日時 2026-10-21 05:50:38
合計ジャッジ時間 2,434 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import gcd


a, b = map(int, input().split())
c, d = map(int, input().split())
x = a * d - b * c
x = abs(x)
g = gcd(gcd(a, b), gcd(c, d))
if g == 0:
    print(0, 0)
else:
    print(g, x // g)
0