結果

問題 No.816 Beautiful tuples
ユーザー TEWi_RTEWi_R
提出日時 2019-04-19 22:31:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 1,500 ms
コード長 497 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 11,700 KB
実行使用メモリ 9,972 KB
最終ジャッジ日時 2023-10-24 05:24:10
合計ジャッジ時間 2,388 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
9,972 KB
testcase_01 AC 28 ms
9,972 KB
testcase_02 AC 28 ms
9,972 KB
testcase_03 AC 27 ms
9,972 KB
testcase_04 AC 27 ms
9,972 KB
testcase_05 AC 27 ms
9,972 KB
testcase_06 AC 29 ms
9,972 KB
testcase_07 AC 28 ms
9,972 KB
testcase_08 AC 28 ms
9,972 KB
testcase_09 AC 28 ms
9,972 KB
testcase_10 AC 28 ms
9,972 KB
testcase_11 AC 28 ms
9,972 KB
testcase_12 AC 28 ms
9,972 KB
testcase_13 AC 31 ms
9,972 KB
testcase_14 AC 30 ms
9,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

input_line = input().split()
a = int(input_line[0])
b = int(input_line[1])

max_n = 0
if(a > b):
    big_n = a
    small_n = b
else:
    big_n = b
    small_n = a


def check_c(c):
    if(((a+b) % c) == 0 and (b+c) % a == 0 and (c+a) % b == 0):
        return True
    else:
        return False


c = big_n - small_n
while(c <= big_n+small_n):
    if(c == big_n or c == small_n):
        pass
    elif(check_c(c)):
        print(c)
        exit()
    else:
        pass
    c += big_n

print(-1)
0