結果

問題 No.816 Beautiful tuples
ユーザー brthyyjpbrthyyjp
提出日時 2020-06-19 16:51:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 1,500 ms
コード長 436 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 75,828 KB
最終ジャッジ日時 2023-09-16 12:58:54
合計ジャッジ時間 2,215 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,904 KB
testcase_01 AC 69 ms
71,844 KB
testcase_02 AC 72 ms
75,660 KB
testcase_03 AC 78 ms
75,636 KB
testcase_04 AC 71 ms
75,828 KB
testcase_05 AC 71 ms
75,788 KB
testcase_06 AC 71 ms
75,624 KB
testcase_07 AC 69 ms
75,728 KB
testcase_08 AC 69 ms
75,596 KB
testcase_09 AC 69 ms
75,756 KB
testcase_10 AC 71 ms
75,524 KB
testcase_11 AC 72 ms
75,676 KB
testcase_12 AC 71 ms
75,504 KB
testcase_13 AC 68 ms
75,572 KB
testcase_14 AC 67 ms
71,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b = map(int, input().split())
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

d = make_divisors(a+b)
for c in d:
    if (a+c)%b == 0 and (b+c)%a == 0:
        if a != c and b != c:
            print(c)
            exit()
else:
    print(-1)
0