結果

問題 No.816 Beautiful tuples
ユーザー kekure
提出日時 2019-07-07 23:57:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 289 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 62,720 KB
最終ジャッジ日時 2024-10-05 20:29:32
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B = map(int, input().split())
divisor = [1]
ApB = A + B
for i in range(2, ApB):
    if ApB % i == 0 and i != A and i != B:
        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