結果

問題 No.816 Beautiful tuples
ユーザー zer0zer0
提出日時 2019-04-21 10:01:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-15 08:26:09
合計ジャッジ時間 1,433 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 33 ms
10,880 KB
testcase_09 AC 32 ms
10,880 KB
testcase_10 AC 35 ms
10,880 KB
testcase_11 AC 36 ms
10,752 KB
testcase_12 AC 36 ms
10,752 KB
testcase_13 AC 35 ms
10,752 KB
testcase_14 AC 30 ms
10,880 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 D % i == 0:
        clist.append(i)
        clist.append(E // i)

if A in clist:
    clist.remove(A)

if B in clist:
    clist.remove(B)

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

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