题解 | #挑7#
挑7
http://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
直接根据描述来解题
while True:
try:
num = int(input())
except:
break
count = 0
for i in range(num, 6, -1):
if i % 7 == 0: # 7的倍数
count += 1
else: # 某一位上出现了7
tmp = i
while tmp:
if tmp % 10 == 7:
count += 1
break
tmp //= 10
print(count)