結果

問題 No.816 Beautiful tuples
ユーザー neko_the_shadow
提出日時 2019-04-20 12:07:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 38 ms / 1,500 ms
コード長 370 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-25 10:06:51
合計ジャッジ時間 1,268 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, sys

a, b = map(int, input().split())

x = a + b
factors = set()
for i in range(1, math.ceil(math.sqrt(x)) + 1):
    if x % i == 0:
        factors.add(i)
        factors.add(x // i)

for c in sorted(factors):
    if a != b and b != c and c != a and (a + b) % c == 0 and (b + c) % a == 0 and (c + a) % b == 0:
        print(c)
        sys.exit(0)

print(-1)
0