标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 631 Accepted Submission(s): 436
1 #include<queue> 2 #include<math.h> 3 #include<stdio.h> 4 #include<string.h> 5 #include<iostream> 6 #include<algorithm> 7 using namespace std; 8 #define N 123456 9 #define M 12 10 11 int a,b; 12 int ha[M],f[N]; 13 int judge(int x) 14 { 15 int n; 16 memset(ha,0,sizeof(ha)); 17 while(x) 18 { 19 n=x%10; 20 if(ha[n])return 0; 21 else ha[n]=1; 22 x=x/10; 23 } 24 return 1; 25 } 26 27 int main() 28 { 29 f[0]=1; 30 for(int i=1;i<100005;i++) 31 { 32 f[i]=f[i-1]; 33 if( judge(i) ) 34 f[i]++; 35 } 36 int t;cin>>t; 37 while(t--) 38 { 39 scanf("%d%d",&a,&b); 40 cout<<f[b]-f[a-1]<<endl; 41 } 42 return 0; 43 }
标签:
原文地址:http://www.cnblogs.com/wmxl/p/4703093.html