結果

問題 No.816 Beautiful tuples
ユーザー bellangeldindonbellangeldindon
提出日時 2019-05-14 15:09:31
言語 Python2
(2.7.18)
結果
AC  
実行時間 17 ms / 1,500 ms
コード長 454 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 6,676 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2023-09-25 16:38:27
合計ジャッジ時間 1,455 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,132 KB
testcase_01 AC 11 ms
5,980 KB
testcase_02 AC 13 ms
6,156 KB
testcase_03 AC 13 ms
6,284 KB
testcase_04 AC 12 ms
6,376 KB
testcase_05 AC 17 ms
6,944 KB
testcase_06 AC 14 ms
6,508 KB
testcase_07 AC 13 ms
6,188 KB
testcase_08 AC 13 ms
6,116 KB
testcase_09 AC 12 ms
6,152 KB
testcase_10 AC 16 ms
6,740 KB
testcase_11 AC 17 ms
6,768 KB
testcase_12 AC 17 ms
6,940 KB
testcase_13 AC 15 ms
6,720 KB
testcase_14 AC 11 ms
6,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
A, B = map(int, raw_input().split())
divisors = []
for i in range(1, int(math.sqrt(A+B))+1):
	if (A+B)%i == 0: divisors.append(i)
N = len(divisors)
for i in range(0, N):
	if (A+B)/divisors[i] not in divisors: divisors.append((A+B)/divisors[i])
divisors.sort()

min = -1
for i in range(0, len(divisors)):
	if A != divisors[i] and B != divisors[i]:
		if (B+divisors[i])%A == 0 and (A+divisors[i])%B == 0:
			min = divisors[i]
			break
print min
0