結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
7,940 KB
testcase_02 AC 15 ms
7,956 KB
testcase_03 WA -
testcase_04 AC 17 ms
7,836 KB
testcase_05 AC 24 ms
7,784 KB
testcase_06 AC 18 ms
7,892 KB
testcase_07 AC 16 ms
7,888 KB
testcase_08 AC 16 ms
7,816 KB
testcase_09 AC 16 ms
7,892 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 21 ms
7,884 KB
testcase_13 AC 22 ms
7,856 KB
testcase_14 AC 15 ms
7,780 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:
                ans = min(ans, c)
    f += 1
if ans == 10**18 + 1:
    ans = -1
print(ans)
0