結果

問題 No.2767 Add to Divide
ユーザー ああいい
提出日時 2024-06-01 16:40:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 295 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 63,488 KB
最終ジャッジ日時 2024-12-22 03:03:09
合計ジャッジ時間 3,955 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
	a,b = map(int,input().split())
	c = b - a
	if c < a:
		print(-1)
	else:
		s = set()
		for i in range(1,10 ** 5):
			if c % i == 0:
				s.add(i)
				s.add(c // i)
		s.add(c)
		ans = 10 ** 20
		for k in s:
			if k >= a and k - a < ans:ans = k - a
		print(ans)
0