結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-16 10:49:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 1,500 ms |
| コード長 | 425 bytes |
| コンパイル時間 | 1,212 ms |
| コンパイル使用メモリ | 11,904 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2025-01-16 10:49:39 |
| 合計ジャッジ時間 | 3,153 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
def divisors(n):
ans = []
i = 1
while i * i <= n:
if n % i == 0:
ans.append(i)
if i != n//i:
ans.append(n//i)
i += 1
ans.sort()
return ans
a, b = map(int, input().split())
d = divisors(a+b)
glist = list(set(d))
for i in glist:
if (a + i) % b == 0 and (b + i) % a == 0 and a != i and b != i:
print(i)
break
else:
print(-1)