結果

問題 No.816 Beautiful tuples
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-04-20 12:07:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 36 ms / 1,500 ms
コード長 370 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 11,772 KB
実行使用メモリ 10,124 KB
最終ジャッジ日時 2023-10-26 02:01:29
合計ジャッジ時間 1,357 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,124 KB
testcase_01 AC 30 ms
10,124 KB
testcase_02 AC 30 ms
10,124 KB
testcase_03 AC 30 ms
10,124 KB
testcase_04 AC 31 ms
10,124 KB
testcase_05 AC 36 ms
10,124 KB
testcase_06 AC 31 ms
10,124 KB
testcase_07 AC 31 ms
10,124 KB
testcase_08 AC 31 ms
10,124 KB
testcase_09 AC 31 ms
10,124 KB
testcase_10 AC 35 ms
10,124 KB
testcase_11 AC 34 ms
10,124 KB
testcase_12 AC 35 ms
10,124 KB
testcase_13 AC 34 ms
10,124 KB
testcase_14 AC 30 ms
10,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, sys

a, b = map(int, input().split())

x = a + b
factors = set()
for i in range(1, math.ceil(math.sqrt(x)) + 1):
    if x % i == 0:
        factors.add(i)
        factors.add(x // i)

for c in sorted(factors):
    if a != b and b != c and c != a and (a + b) % c == 0 and (b + c) % a == 0 and (c + a) % b == 0:
        print(c)
        sys.exit(0)

print(-1)
0