题目
思路
常用小技巧:关于取出x的每位数字 和 将字符数字转为数字
1.取出x的每位数字
t = x % 10
x //= 10
2.将字符数字转为数字
x=0
for i in range(len(str)):
x = x * 10 + str[i] - '0'
代码
n =int(input())
res =0
for i in range(1,n+1):
x=i
while x:
t=x%10
x//=10 # Python中是//,而不是/ !!!
if t==0 or t==2 or t==1 or t==9:
res +=i
break
print(res)