結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  kekure | 
| 提出日時 | 2019-07-08 00:16:39 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 415 bytes | 
| コンパイル時間 | 445 ms | 
| コンパイル使用メモリ | 81,984 KB | 
| 実行使用メモリ | 59,852 KB | 
| 最終ジャッジ日時 | 2024-10-05 21:16:46 | 
| 合計ジャッジ時間 | 1,333 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 12 WA * 3 | 
ソースコード
import math
A, B = map(int, input().split())
ApB = A + B
divisor = [1, ApB]
index = 1
limit = int(math.sqrt(ApB))
for i in range(2, limit + 1):
    if ApB % i == 0 and i != A and i != B:
        divisor.append(i)
        N = ApB // i
        if N != i:
            divisor.append(N)
divisor.sort()
for C in divisor:
    if (A + C) % B == 0 and (B + C) % A == 0:
        print(C)
        break
else:
    print(-1)
            
            
            
        