結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-03-26 03:21:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 1,500 ms |
| コード長 | 396 bytes |
| コンパイル時間 | 339 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 58,800 KB |
| 最終ジャッジ日時 | 2025-03-26 03:21:17 |
| 合計ジャッジ時間 | 1,954 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
def divisors(n: int) -> list[int]:
"""n の約数を求める"""
s = set()
p = 1
while p * p <= n:
if n % p == 0:
s.add(p)
s.add(n // p)
p += 1
return sorted(s)
A, B = map(int, input().split())
for c in divisors(A+B):
if (A+c) % B == 0 and (B+c) % A == 0 and A != c and B != c:
print(c)
break
else:
print(-1)
norioc