結果

問題 No.2767 Add to Divide
ユーザー Butterflv
提出日時 2024-05-31 21:43:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 81,716 KB
実行使用メモリ 67,692 KB
最終ジャッジ日時 2024-12-20 22:58:17
合計ジャッジ時間 2,410 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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]


T=int(input())

for _ in range(T):
  A,B=map(int,input().split())
  divi = make_divisors(B-A)
  MIN = 1<<60
  for t in divi:
    X = (B-A)//t - A
    if X>=0:
      MIN = min(MIN, X)
  print(-1 if MIN==1<<60 else MIN)
0