結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 21:46:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 788 bytes |
| コンパイル時間 | 399 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 67,200 KB |
| 最終ジャッジ日時 | 2024-12-20 23:03:27 |
| 合計ジャッジ時間 | 2,859 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 4 |
ソースコード
S = input
R = range
P = print
def I(): return int(S())
def M(): return map(int, S().split())
def L(): return list(M())
def O(): return list(map(int, open(0).read().split()))
def yn(b): print("Yes" if b else "No")
biga = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
smaa = "abcdefghijklmnopqrstuvwxyz"
def make_divisors(n):
lower_divisors , upper_divisors = [], []
i = 1
while i*i <= n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
upper_divisors.append(n//i)
i += 1
return lower_divisors + upper_divisors[::-1]
for _ in R(I()):
a, b = M()
c = 10 ** 15
# b - a の約数を全探索
for i in make_divisors(b - a):
if i >= a and (b + i - a) % (a + i - a) == 0:
c = min(c, i - a)
print(c if c < 10 ** 15 else -1)