結果
| 問題 | No.816 Beautiful tuples |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-20 09:13:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 1,500 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 82,308 KB |
| 実行使用メモリ | 59,264 KB |
| 最終ジャッジ日時 | 2024-09-25 06:26:01 |
| 合計ジャッジ時間 | 1,450 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
# -*- coding: utf-8 -*-
import sys
import copy
sys.setrecursionlimit(1000000)
# input = sys.stdin.readline
# ~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~
def get_divisors(x):
ret = []
i = 1
while i * i <= x:
if x % i == 0:
ret.append(i)
if x // i != i:
ret.append(x // i)
i += 1
ret = sorted(ret)
return ret
A, B = map(int, input().split())
divisors = get_divisors(A + B)
ans = 100000000000000000000
for C in divisors:
if (A + C) % B == 0 and (B + C) % A == 0 and A != B and B != C and A != C:
ans = min(ans, C)
print(ans if ans != 100000000000000000000 else -1)