1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#include <stdio.h> #include <iostream> #include <math.h> #include <string.h> #include <time.h> using namespace std; int trace[5001]; int main() { //clock_t t1,t2; //t1=clock(); int cnt=0; int arr[10]; for(int i=1;i<=5000;i++) { int tmp=i; trace[i]=cnt; memset(arr,0,sizeof(arr)); while(tmp) { arr[tmp%10]++; if(arr[tmp%10]>1) { cnt++; trace[i]=cnt; break; } tmp/=10; } } int n,m; while(cin>>n>>m) { cout<<(m-n+1)-(trace[m] - trace[n-1])<<"\n"; } //cout<<cnt<<"\n"; /* t2=clock(); float diff ((float)t2-(float)t1); cout<<diff<<endl; */ return 0; } |