leetcode 233. Number of Digit One
问题分解: 分治进行计算的思想
public class Solution {
public int countDigitOne(int n) {
if(n<=0) return 0;
int r = 0;
for(long m=1;m<=n;m=m*10){
r += (n/m+8)/10*m + (n/m%10==1?n%m+1:0);
}
return r;
}
}