結果

問題 No.816 Beautiful tuples
ユーザー MineMine
提出日時 2020-09-09 16:11:53
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2023-08-21 18:17:08
合計ジャッジ時間 2,115 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 19 ms
8,448 KB
testcase_02 AC 19 ms
8,528 KB
testcase_03 WA -
testcase_04 AC 19 ms
8,436 KB
testcase_05 AC 25 ms
8,536 KB
testcase_06 AC 19 ms
8,604 KB
testcase_07 AC 19 ms
8,580 KB
testcase_08 AC 19 ms
8,568 KB
testcase_09 AC 19 ms
8,432 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 22 ms
8,576 KB
testcase_13 AC 22 ms
8,452 KB
testcase_14 AC 18 ms
8,440 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:
        print(c)
        exit()
print(-1)
0