結果

問題 No.2767 Add to Divide
ユーザー p-adicp-adic
提出日時 2024-05-08 14:15:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 73,088 KB
最終ジャッジ日時 2024-05-08 14:19:32
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
63,104 KB
testcase_01 AC 57 ms
64,104 KB
testcase_02 AC 65 ms
66,176 KB
testcase_03 AC 88 ms
73,088 KB
testcase_04 AC 71 ms
64,512 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 82 ms
66,432 KB
testcase_12 AC 74 ms
66,944 KB
testcase_13 AC 75 ms
66,816 KB
testcase_14 AC 73 ms
66,432 KB
testcase_15 AC 75 ms
67,072 KB
testcase_16 AC 71 ms
66,048 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]
		if A<=1<t:t=1
		for p in P:
			c=0
			while e%p<1:e//=p;c+=1;
			r=len(D)
			for i in R(c):
				for m in[n*p for n in D[-r:]]:
					D+=[m]
					if A<=m<t:t=m
		if A<=e<t:t=e
	print([0,max(t-A,-1)][e>0])
0