結果

問題 No.816 Beautiful tuples
コンテスト
ユーザー ttr
提出日時 2020-02-08 19:49:59
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 97 ms / 1,500 ms
+ 10µs
コード長 333 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 298 ms
コンパイル使用メモリ 21,464 KB
実行使用メモリ 15,788 KB
最終ジャッジ日時 2026-09-04 02:29:58
合計ジャッジ時間 3,402 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

def f(A, B, C):
    res = True
    if (A+B)%C > 0:
        res = False
    if (B+C)%A > 0:
        res = False
    if (C+A)%B > 0:
        res = False
    return res

if B > A:
    A, B = B, A

if A != 2*B and f(A, B, A-B):
    ans = A-B
elif f(A, B, A+B):
    ans = A+B
else:
    ans = -1
print(ans)
0