結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  toyuzuko | 
| 提出日時 | 2020-04-28 16:43:37 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 349 bytes | 
| コンパイル時間 | 212 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-11-24 23:19:13 | 
| 合計ジャッジ時間 | 1,518 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 WA * 4 | 
ソースコード
A, B = map(int, input().split())
INF = 10**18
res = INF
n = 0
while n ** 2 <= A + B:
    n += 1
    if (A + B) % n == 0:
        if (A + n) % B == 0 and (B + n) % A == 0:
            res = min(res, n)
        if (A + (A + B) // n) % B == 0 and (B + (A + B) // n) % A == 0:
            res = min(res, (A + B) // n)
print(res if res != INF else -1)
            
            
            
        