結果

問題 No.816 Beautiful tuples
ユーザー kekurekekure
提出日時 2019-07-07 23:53:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 109,568 KB
最終ジャッジ日時 2024-04-15 18:22:32
合計ジャッジ時間 6,186 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 424 ms
57,344 KB
testcase_03 WA -
testcase_04 AC 1,056 ms
57,344 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# a + bの1と、その数自体を含めた約数を考える
# 小さい方から見て、その数が他の2つのペアにたいしても約数になってるか確かめる
A, B = map(int, input().split())
divisor = [1]
ApB = A + B
for i in range(2, ApB):
    if ApB % i == 0:
        divisor.append(i)

divisor.append(ApB)

for C in divisor:
    if (A + C) % B == 0 and (B + C) % A == 0:
        print(C)
        break
else:
    print(-1)
0