# -*- coding:utf-8 -*- class Solution: def NumberOf1Between1AndN_Solution(self, n): # write code here count=0 former=0 round,weight,base=n/10,n%10,1 count+=round if weight!=0: count+=1 while(round): former+=base*weight base*=10 round,weight=round/10,round%10 count+=round*base if weight>1: count+=base elif weight==1: count+=1+former return count