結果

問題 No.442 和と積
ユーザー be_platonicbe_platonic
提出日時 2022-04-29 02:00:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 286 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-28 09:23:13
合計ジャッジ時間 1,722 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B = map(int, input().split())

def GCD(a, b):
    while a >= 1 and b >= 1:
        if a >= b:
            a = a % b
        else:
            b = b % a
    
    if a >= 1:
        return a
    return b

g = GCD(A, B)
A2, B2 = A // g, B // g
ans = g * GCD(A2 + B2, g)

print(ans)




0