結果

問題 No.816 Beautiful tuples
ユーザー H20
提出日時 2021-01-28 16:09:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 1,500 ms
コード長 463 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,012 KB
実行使用メモリ 58,932 KB
最終ジャッジ日時 2024-06-26 00:18:03
合計ジャッジ時間 1,718 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
A,B = map(int,input().split())
CD = make_divisors(A+B)
for C in CD:
    if not A==C and not B==C and (A+C)%B==0 and (B+C)%A==0:
        print(C)
        exit()

print(-1)
0