結果

問題 No.816 Beautiful tuples
ユーザー c-yanc-yan
提出日時 2020-11-10 00:27:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,672 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-09-29 23:06:53
合計ジャッジ時間 1,435 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,784 KB
testcase_02 AC 19 ms
7,892 KB
testcase_03 WA -
testcase_04 AC 23 ms
7,780 KB
testcase_05 AC 49 ms
7,788 KB
testcase_06 AC 25 ms
7,812 KB
testcase_07 AC 24 ms
7,704 KB
testcase_08 AC 21 ms
7,800 KB
testcase_09 AC 22 ms
7,788 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 40 ms
7,788 KB
testcase_13 AC 37 ms
7,752 KB
testcase_14 AC 16 ms
7,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def is_ok(A, B, C):
    return (A + B) % C == 0 and (A + C) % B == 0 and (B + C) % A == 0


result = -1
for i in range(1, int((A + B) ** 0.5) + 1):
    for C in [i, (A + B) // i]:
        if is_ok(A, B, C):
            if result == -1:
                result = C
            else:
                result = min(result, C)
print(result)
0