結果

問題 No.816 Beautiful tuples
ユーザー mlihua09
提出日時 2020-09-14 01:44:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 1,500 ms
コード長 381 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,860 KB
実行使用メモリ 59,172 KB
最終ジャッジ日時 2024-06-13 04:51:46
合計ジャッジ時間 1,937 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #


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

ans = -1

for i in range(1, int((A + B) ** 0.5) + 1):
    
    if (A + B) % i == 0:
        if (A + i) % B == 0 and (B + i) % A == 0 and i != A and i != B:
            print(i)
            exit()
        i = (A + B) // i
        if (A + i) % B == 0 and (B + i) % A == 0 and i != A and i != B:
            ans = i
            
print(ans)
        
0