結果

問題 No.816 Beautiful tuples
ユーザー flippergo
提出日時 2024-10-29 18:33:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,500 ms
コード長 283 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 58,920 KB
最終ジャッジ日時 2024-10-29 18:33:11
合計ジャッジ時間 2,165 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

A,B = map(int,input().split())
C = set()
for i in range(1,A+B+1):
    if i*i>A+B:break
    if (A+B)%i==0:
        C.add(i)
        C.add((A+B)//i)
C = sorted(list(C))
flag = -1
for c in C:
    if (A+c)%B==0 and (B+c)%A==0 and c!=A and c!=B:
        flag = c
        break
print(flag)
0