标签:
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5327
1 #include<stdio.h> 2 #include<cstring> 3 const int MAXN = 100010; 4 bool a[MAXN]; 5 int s[MAXN]; 6 int flag[10] = {0,1,2,3,4,5,6,7,8,9}; 7 void init(){ 8 int tmp; 9 memset(a,0,sizeof(a)); 10 memset(s,0,sizeof(s)); 11 for( int i = 1; i <= MAXN; ++i ){ 12 memset(flag,0,sizeof(flag)); 13 tmp = i; 14 while(tmp != 0){ 15 if( flag[tmp % 10] == 1 ){ 16 a[i] = 1; 17 break; 18 } 19 else 20 { 21 flag[tmp%10] = 1; 22 tmp = tmp / 10; 23 } 24 } 25 } 26 printf("%d",s[0]); 27 s[1] = a[1]; 28 for( int i = 2; i <= MAXN; ++i){ 29 s[i] = s[i-1] + a[i]; 30 } 31 } 32 int main() 33 { 34 int T; 35 int a,b; 36 init(); 37 scanf("%d",&T); 38 while(T--){ 39 scanf("%d%d",&a,&b); 40 printf("%d\n",b - s[b] - (a-1) + s[a-1]); 41 } 42 }
标签:
原文地址:http://www.cnblogs.com/blueprintf/p/4703557.html