結果

問題 No.816 Beautiful tuples
ユーザー zer0zer0
提出日時 2019-04-21 10:09:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 40 ms / 1,500 ms
コード長 400 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-15 08:39:22
合計ジャッジ時間 1,349 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

A, B = map(int, input().split())

clist = []
ans = 1000000000000000001
D = int(pow(A + B, 1 / 2))
E = A + B
for i in range(1, D + 1):
    if E % i == 0:
        clist.append(i)
        clist.append(E // i)

for i in clist:
    if A != i and B != i:
        if (A + i) % B == 0:
            if (B + i) % A == 0:
                ans = min(ans, i)

if ans == 1000000000000000001:
    ans = -1
print(ans)
0