結果

問題 No.816 Beautiful tuples
ユーザー stngstng
提出日時 2022-07-17 12:14:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 1,500 ms
コード長 482 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 75,856 KB
最終ジャッジ日時 2023-09-12 00:04:17
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,868 KB
testcase_01 AC 69 ms
71,772 KB
testcase_02 AC 73 ms
75,748 KB
testcase_03 AC 74 ms
75,664 KB
testcase_04 AC 74 ms
75,804 KB
testcase_05 AC 74 ms
75,780 KB
testcase_06 AC 75 ms
75,856 KB
testcase_07 AC 74 ms
75,800 KB
testcase_08 AC 73 ms
75,844 KB
testcase_09 AC 74 ms
75,780 KB
testcase_10 AC 73 ms
75,784 KB
testcase_11 AC 75 ms
75,724 KB
testcase_12 AC 76 ms
75,796 KB
testcase_13 AC 73 ms
75,848 KB
testcase_14 AC 71 ms
71,796 KB
権限があれば一括ダウンロードができます

ソースコード

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