标签:
1 10 44 497 346 542 0 0
2 185 40
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int p[20]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000}; 5 int get1(int x){ 6 int sum=0,k=0; 7 int t=x; 8 while(t) 9 { 10 if(t%10>1) 11 sum+=p[k]; 12 else if(t%10==1) 13 sum+=x%p[k]+1; 14 15 sum+=t%10*k*p[k-1]; 16 17 t/=10; 18 k++; 19 } 20 return sum; 21 } 22 int main(){ 23 int a,b; 24 while(scanf("%d%d",&a,&b),a|b){ 25 if(a>b)swap(a,b); 26 int ans=get1(b)-get1(a-1); 27 printf("%d\n",ans); 28 } 29 return 0; 30 }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4906314.html