結果

問題 No.816 Beautiful tuples
ユーザー yansi819yansi819
提出日時 2024-05-12 18:44:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 1,500 ms
コード長 389 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 58,856 KB
最終ジャッジ日時 2024-05-12 18:44:08
合計ジャッジ時間 1,633 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,076 KB
testcase_01 AC 37 ms
52,736 KB
testcase_02 AC 39 ms
57,464 KB
testcase_03 AC 40 ms
58,360 KB
testcase_04 AC 40 ms
57,912 KB
testcase_05 AC 40 ms
57,384 KB
testcase_06 AC 40 ms
58,272 KB
testcase_07 AC 40 ms
58,788 KB
testcase_08 AC 39 ms
57,724 KB
testcase_09 AC 40 ms
58,200 KB
testcase_10 AC 40 ms
57,936 KB
testcase_11 AC 42 ms
57,292 KB
testcase_12 AC 50 ms
58,296 KB
testcase_13 AC 40 ms
58,856 KB
testcase_14 AC 38 ms
52,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(N):
    res = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            res.append(i)
            if i * i != N:
                res.append(N // i)
    res.sort()
    return res

A, B = map(int, input().split())
D = divisors(A + B)
for C in D:
    if (A + C) % B == 0 and (B + C) % A == 0 and A != C and B != C:
        print(C)
        exit()
print(-1)
0