結果

問題 No.2767 Add to Divide
ユーザー p-adicp-adic
提出日時 2024-05-08 14:21:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 69,248 KB
最終ジャッジ日時 2024-05-08 14:21:33
合計ジャッジ時間 2,525 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
62,976 KB
testcase_01 AC 67 ms
64,256 KB
testcase_02 AC 74 ms
64,640 KB
testcase_03 AC 91 ms
69,248 KB
testcase_04 AC 83 ms
64,384 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 81 ms
65,024 KB
testcase_12 AC 82 ms
65,664 KB
testcase_13 AC 78 ms
65,280 KB
testcase_14 AC 80 ms
65,024 KB
testcase_15 AC 81 ms
65,536 KB
testcase_16 AC 81 ms
65,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R,O=input,range,print
L=9**5
P=[]
C=[0]*L
for i in R(2,L):
	if C[i]<1:
		P+=[i]
		j=i*i
		while j<L:C[j],j=1,j+i
for t in R(int(I())):
	A,B=map(int,I().split())
	t=e=B-A
	if e:
		D=[1]
		for p in P:
			c=0
			while e%p<1:e//=p;c+=1;
			r=len(D)
			for i in R(c):D+=[n*p for n in D[-r:]]
		D.sort()
		if e>1:D+=[e]
		r=len(D)-1
		while r and D[r-1]>=A:r-=1
	print(max(D[r]-A,-1)if e else 0)
0