結果

問題 No.2767 Add to Divide
ユーザー なえしら
提出日時 2024-05-31 21:37:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 404 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 69,100 KB
最終ジャッジ日時 2024-12-20 22:46:20
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import isqrt
def divisors(n):
  r = isqrt(n-1)+1
  small, large = [], []
  for i in range(1, r):
    if n%i == 0:
      small.append(i)
      large.append(n//i)
  if r**2 == n: small.append(r)
  return small + large[::-1]

T = int(input())
for _ in range(T):
  A, B = map(int, input().split())
  D = divisors(B - A)
  for d in D:
    if d >= A:
      print(d - A)
      break
  else: print(-1)
0