結果

問題 No.2767 Add to Divide
ユーザー 👑 timitimi
提出日時 2024-06-02 05:19:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2024-06-02 05:19:52
合計ジャッジ時間 2,013 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
56,960 KB
testcase_01 AC 42 ms
57,728 KB
testcase_02 AC 39 ms
52,608 KB
testcase_03 AC 85 ms
61,824 KB
testcase_04 AC 39 ms
52,608 KB
testcase_05 AC 70 ms
59,520 KB
testcase_06 AC 70 ms
59,392 KB
testcase_07 AC 70 ms
59,392 KB
testcase_08 AC 88 ms
66,304 KB
testcase_09 AC 78 ms
59,392 KB
testcase_10 AC 77 ms
59,520 KB
testcase_11 AC 79 ms
60,160 KB
testcase_12 AC 76 ms
60,288 KB
testcase_13 AC 76 ms
60,288 KB
testcase_14 AC 78 ms
60,288 KB
testcase_15 AC 75 ms
59,904 KB
testcase_16 AC 80 ms
59,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ax,ay,az=map(int, input().split())
#bx,by,bz=map(int, input().split())
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 i in range(T):
  a,b=map(int, input().split())
  if a==b:
    print(0)
  else:
    A=make_divisors(b-a)
    ans=-1
    for aa in A[::-1]:
      if aa>=a:
        ans=aa-a 
    print(ans)
0