enter image description here

测试程序

def test(f):
 s=set()
 while f>0:
  s.add(f%10)
  #print(s)
  if len(s)>2:return False
  f//=10
 return True

def d(n):
 s=n
 while True:
  if test(s):return s
  s+=n

def D(n):
 s2=0
 for i in range(1,n+1):s2+=d(i)
 return s2