結果
問題 |
No.2767 Add to Divide
|
ユーザー |
|
提出日時 | 2025-06-24 10:02:12 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 406 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 330 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-06-24 10:02:18 |
合計ジャッジ時間 | 5,958 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
import bisect def divisors(n): lower, upper = [], [] i = 1 while i*i <= n: if n % i == 0: lower.append(i) if i != n // i: upper.append(n//i) i += 1 return lower + upper[::-1] t = int(input()) for i in range(t): a, b = map(int, input().split()) if a == b: print(0) else: ba = b - a ans = divisors(ba) j = bisect.bisect_left(ans, a) if len(ans[j:]) == 0: print(-1) else: print(min(ans[j:]) - a)