# -*- coding:utf-8 -*-
class Solution:
def NumberOf1Between1AndN_Solution(self, n):
# write code here
ones,m =0,1
if not n:
return 0
while m<=n:
ones += (n//m+8)//10*m + (n//m%10==1)*(n%m+1)
m *= 10
return ones
原文:https://www.cnblogs.com/277223178dudu/p/10563160.html