結果

問題 No.816 Beautiful tuples
ユーザー MineMine
提出日時 2020-09-09 16:12:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 24 ms / 1,500 ms
コード長 512 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 8,620 KB
最終ジャッジ日時 2023-08-21 18:19:25
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,572 KB
testcase_01 AC 18 ms
8,488 KB
testcase_02 AC 19 ms
8,564 KB
testcase_03 AC 19 ms
8,556 KB
testcase_04 AC 19 ms
8,424 KB
testcase_05 AC 24 ms
8,608 KB
testcase_06 AC 19 ms
8,604 KB
testcase_07 AC 19 ms
8,552 KB
testcase_08 AC 19 ms
8,544 KB
testcase_09 AC 20 ms
8,620 KB
testcase_10 AC 22 ms
8,480 KB
testcase_11 AC 23 ms
8,612 KB
testcase_12 AC 23 ms
8,480 KB
testcase_13 AC 22 ms
8,608 KB
testcase_14 AC 19 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
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())
m = make_divisors(a+b)
for c in m:
    if (a+b)%c == 0 and (b+c)%a == 0 and (c+a)%b == 0 and a!=c and b!=c:
        print(c)
        exit()
print(-1)
0