def fun354(left,right):
def num2digital(num):
result = []
while num:
result.append(num%10)
num = num // 10
result.reverse()
return result
def digital2num(arr):
result = 0
for each in arr:
result = result * 10 + each
return result
def GongBei(iterobj):
result = 1
for each in iterobj:
result = result*each//Gongyue(result,each)
return result
def Gongyue(a,b):
if a<b:
a,b = b,a
while b:
a,b = b,a%b
return a
def Ji():
if m != M:
if dic['bits']<M and dic['bits']>m:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,2,Ji)
else:
Deal(1,10,2,Ji,True)
elif dic['bits'] == M:
if temp == right_arr[0:dic['index']]:
standard = right_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(1,standard+1,2,Ji)
else:
Deal(1,standard+1,2,Ji,True)
else:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,2,Ji)
else:
Deal(1,10,2,Ji,True)
else:
if temp == left_arr[0:dic['index']]:
standard = left_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(9,max([standard-1,0]),-2,Ji)
else:
Deal(9,max([standard-1,0]),-2,Ji,True)
else:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,2,Ji)
else:
Deal(1,10,2,Ji,True)
else:
if right_arr[0:dic['index']] == left_arr[0:dic['index']]:
s1 = left_arr[dic['index']]
s2 = right_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal((s1//2)*2+1,s2+1,2,Ji)
else:
Deal((s1//2)*2+1,s2+1,2,Ji,True)
else:
if temp < right_arr[0:dic['index']] and temp > left_arr[0:dic['index']]:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,2,Ji)
else:
Deal(1,10,2,Ji,True)
elif temp == right_arr[0:dic['index']]:
standard = right_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(1,standard+1,2,Ji)
else:
Deal(1,standard+1,2,Ji,True)
else:
standard = left_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(9,max([standard-1,0]),-2,Ji)
else:
Deal(9,max([standard-1,0]),-2,Ji,True)
def Ou():
if m != M:
if dic['bits']<M and dic['bits']>m:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,1,Ou)
else:
Deal(2,10,2,Ou,True)
elif dic['bits'] == M:
if temp == right_arr[0:dic['index']]:
standard = right_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(1,standard+1,1,Ou)
else:
Deal(2,standard+1,2,Ou,True)
else:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,1,Ou)
else:
Deal(2,10,2,Ou,True)
else:
if temp == left_arr[0:dic['index']]:
standard = left_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(9,max([standard-1,0]),-1,Ou)
else:
Deal(8,max([standard-1,0]),-2,Ou,True)
else:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,1,Ou)
else:
Deal(2,10,2,Ou,True)
else:
if right_arr[0:dic['index']] == left_arr[0:dic['index']]:
s1 = left_arr[dic['index']]
s2 = right_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(max([s1,1]),s2+1,1,Ou)
else:
Deal(max([2,((s1+1)//2)*2]),s2+1,2,Ou,True)
else:
if temp < right_arr[0:dic['index']] and temp > left_arr[0:dic['index']]:
if dic['index'] < dic['bits'] - 1:
Deal(1,10,1,Ou)
else:
Deal(2,10,2,Ou,True)
elif temp == right_arr[0:dic['index']]:
standard = right_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(1,standard+1,1,Ou)
else:
Deal(2,standard+1,2,Ou,True)
else:
standard = left_arr[dic['index']]
if dic['index'] < dic['bits'] - 1:
Deal(9,max([standard-1,0]),-1,Ou)
else:
Deal(8,max([standard-1,0]),-2,Ou,True)
def Deal(start,end,step,func,mode = False):
for each in range(start,end,step):
temp.append(each)
if mode == False:
dic['index'] += 1
func()
temp.pop()
else:
Num = digital2num(temp)
Div = GongBei(set(temp))
if Num % Div == 0:
result.append(Num)
temp.pop()
dic['index'] -= 1
if left == right:
temp = num2digital(left)
Div = GongBei(set(temp))
if left % Div == 0:
return [left]
else:
return []
if right <= 10:
return [i for i in range(left,min(right+1,10))]
elif left < 10:
result = [i for i in range(left,10)]
left = 10
else:
result = []
left_arr = num2digital(left)
m = len(left_arr)
right_arr = num2digital(right)
M = len(right_arr)
dic = {'index':0,'bits':0}
if m!=M:
for each in range(m,M+1):
temp = []
dic['bits']=each
Ji()
dic['index']=0
Ou()
dic['index']=0
else:
for i in range(1,m):
if left_arr[0:i]!=right_arr[0:i]:
break
dic['bits']=m
dic['index']=i-1
temp = []
temp.extend(left_arr[0:(i-1)])
Ji()
dic['index']=i-1
temp = []
temp.extend(left_arr[0:(i-1)])
Ou()
result.sort()
return result