# -*- coding:utf-8 -*-
class Solution:
def NumberOf1Between1AndN_Solution(self, n):
count = 0
base = 1
round = n
while round>0:
low = round%10
round = round//10
if low > 1:
count += round*base + base
elif low == 1:
count += round*base + n%base + 1
else:
count += round*base
base *= 10
return count
整数中1出现的次数
最新推荐文章于 2022-01-18 18:07:41 发布