結果

問題 No.816 Beautiful tuples
ユーザー 👑 rin204rin204
提出日時 2020-06-24 20:00:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 331 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 8,428 KB
最終ジャッジ日時 2023-09-15 11:30:56
合計ジャッジ時間 1,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,908 KB
testcase_02 AC 18 ms
8,252 KB
testcase_03 WA -
testcase_04 AC 16 ms
8,268 KB
testcase_05 AC 21 ms
8,428 KB
testcase_06 AC 18 ms
8,364 KB
testcase_07 AC 17 ms
7,772 KB
testcase_08 AC 17 ms
7,752 KB
testcase_09 AC 16 ms
7,808 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 20 ms
7,908 KB
testcase_13 AC 19 ms
7,800 KB
testcase_14 AC 16 ms
7,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b = map(int, input().split())
tmp = a + b

lst = []
for i in range(2, int(tmp ** 0.5) + 1):
    if tmp % i == 0:
        lst.append(i)
        lst.append(tmp // i)
        
for num in lst:
    if a == num or b == num:
        continue
    if (a + num) % b == 0 and (b + num) % a == 0:
        print(num)
        exit()
print(-1)
0