結果

問題 No.816 Beautiful tuples
ユーザー kekurekekure
提出日時 2019-07-08 00:16:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 415 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 59,376 KB
最終ジャッジ日時 2024-04-15 18:59:20
合計ジャッジ時間 1,544 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,392 KB
testcase_01 AC 41 ms
52,588 KB
testcase_02 AC 43 ms
58,736 KB
testcase_03 WA -
testcase_04 AC 43 ms
58,072 KB
testcase_05 AC 43 ms
59,012 KB
testcase_06 AC 43 ms
58,320 KB
testcase_07 AC 44 ms
59,376 KB
testcase_08 AC 42 ms
57,772 KB
testcase_09 AC 43 ms
58,536 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 43 ms
58,332 KB
testcase_13 AC 45 ms
59,248 KB
testcase_14 AC 40 ms
52,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

A, B = map(int, input().split())
ApB = A + B
divisor = [1, ApB]
index = 1
limit = int(math.sqrt(ApB))
for i in range(2, limit + 1):
    if ApB % i == 0 and i != A and i != B:
        divisor.append(i)
        N = ApB // i
        if N != i:
            divisor.append(N)
divisor.sort()

for C in divisor:
    if (A + C) % B == 0 and (B + C) % A == 0:
        print(C)
        break
else:
    print(-1)
0