给定一个非负整数 n,计算各位数字都不同的数字 x 的个数,其中 0 ≤ x < 10^n
这道题主要涉及到了一个排列组合问题 ,x = 0时,结果为1,x = 1时,结果为9+1,x = 2时,结果为9*9+9+1,x=3时,结果为9*9*8+9*9+9+1……
n = int(input('aaa'))
count = 0
for i in range(10**n):
sets = set(str(i))
if len(sets) == len(str(i)):
count += 1
print(count)
虽然算法暴力了一点,但好歹是能算出来的