結果

問題 No.816 Beautiful tuples
ユーザー lloyzlloyz
提出日時 2022-05-01 22:02:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 26 ms / 1,500 ms
コード長 299 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-09-13 14:50:17
合計ジャッジ時間 1,101 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,772 KB
testcase_01 AC 14 ms
7,892 KB
testcase_02 AC 16 ms
7,772 KB
testcase_03 AC 18 ms
7,812 KB
testcase_04 AC 18 ms
7,836 KB
testcase_05 AC 26 ms
7,764 KB
testcase_06 AC 18 ms
7,856 KB
testcase_07 AC 17 ms
7,836 KB
testcase_08 AC 16 ms
7,844 KB
testcase_09 AC 17 ms
7,960 KB
testcase_10 AC 22 ms
7,764 KB
testcase_11 AC 23 ms
7,776 KB
testcase_12 AC 23 ms
7,768 KB
testcase_13 AC 21 ms
7,932 KB
testcase_14 AC 14 ms
7,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

s = a + b
f = 1
ans = 10**18 + 1
while f * f <= s:
    if s % f == 0:
        for c in (f, s // f):
            if (b + c) % a == 0 and (c + a) % b == 0 and c not in (a, b):
                ans = min(ans, c)
    f += 1
if ans == 10**18 + 1:
    ans = -1
print(ans)
0