結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  kekure | 
| 提出日時 | 2019-07-07 23:53:22 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 447 bytes | 
| コンパイル時間 | 158 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 62,464 KB | 
| 最終ジャッジ日時 | 2024-10-05 20:14:39 | 
| 合計ジャッジ時間 | 5,600 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 WA * 2 TLE * 1 -- * 9 | 
ソースコード
# 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)
            
            
            
        