結果

問題 No.816 Beautiful tuples
ユーザー stng
提出日時 2022-07-17 12:14:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 1,500 ms
コード長 482 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 57,600 KB
最終ジャッジ日時 2024-06-29 13:21:10
合計ジャッジ時間 1,516 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

a,b = map(int,input().split())
cli = make_divisors(a+b)
for i in range(len(cli)):
    c = cli[i]
    if a == c or b == c:
        continue
    if (a+b) % c == 0 and (b+c) % a == 0 and (c+a) % b == 0:
        print(c)
        exit()

print(-1)
0