結果
問題 | No.2767 Add to Divide |
ユーザー |
|
提出日時 | 2024-05-31 21:37:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 788 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 81,996 KB |
実行使用メモリ | 67,608 KB |
最終ジャッジ日時 | 2024-12-20 22:46:10 |
合計ジャッジ時間 | 2,988 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 WA * 4 |
ソースコード
S = inputR = rangeP = printdef 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 = 1while i*i <= n:if n % i == 0:lower_divisors.append(i)if i != n // i:upper_divisors.append(n//i)i += 1return lower_divisors + upper_divisors[::-1]for _ in R(I()):a, b = M()c = 10 ** 10# 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 ** 10 else -1)