結果

問題 No.2767 Add to Divide
ユーザー naesiranaesira
提出日時 2024-05-31 21:37:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 404 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 67,756 KB
最終ジャッジ日時 2024-05-31 21:37:38
合計ジャッジ時間 2,163 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
58,200 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 86 ms
62,440 KB
testcase_04 AC 40 ms
54,372 KB
testcase_05 AC 69 ms
59,964 KB
testcase_06 RE -
testcase_07 AC 68 ms
60,748 KB
testcase_08 AC 75 ms
61,376 KB
testcase_09 RE -
testcase_10 AC 74 ms
60,700 KB
testcase_11 AC 74 ms
59,484 KB
testcase_12 AC 78 ms
60,752 KB
testcase_13 AC 74 ms
59,460 KB
testcase_14 AC 74 ms
61,564 KB
testcase_15 AC 73 ms
60,936 KB
testcase_16 AC 73 ms
61,180 KB
権限があれば一括ダウンロードができます

ソースコード

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