a = []
b = []
for i in range(0, 10):
a.append(str(i))
b.append(0)
c = []
for i in range(1, 10):
for j in range(1, 10):
if j == i :
continue
for k in range(1, 10):
if (j == k) or (i == k) :
continue
tmp = i * 100 + j *10 + k
flag = 0
tmp1 = tmp * 2
c = b[:]
while tmp1:
t = tmp1%10
if (t == i or t == j or t == k or c[t] or t == 0) :
flag = 1
break
c[t] = 1;
tmp1 //= 10
if flag :
continue
tmp2 = tmp * 3
if tmp2 > 999 :
continue
while tmp2:
t = tmp2%10
if (t == i or t == j or t == k or c[t] or t == 0) :
flag = 1
break
c[t] = 1
tmp2 //= 10
if flag :
continue
print(tmp, tmp*2, tmp*3, end="\n")
别人的:
for i in range(122, 333):
j = str(2*i)
k = str(3*i)
i = str(i)
a = {i[0], i[1], i[2], j[0], j[1], j[2], k[0], k[1], k[2]}#集合去重复
if len(a) == 9 and ("0" not in a): #注意含0的情况
print(int(i), int(j), int(k))