View Code of Problem 3594

#include<stdio.h>
#include<string.h>
#include<math.h>
int cmp(const void *a,const void *b){
	return *(int *)a - *(int *)b;
}
int isBea(int n){
	int a[10];
	int i,num = 0;
	while(n>0){
		a[num++] = n%10;
		n = n/10;
	}
	qsort(a,num,sizeof(int),cmp);
	for(i = 1;i < num; i++){
		if(a[i]==a[i-1]) return 0;
	}
	return 1;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int a,b;
		scanf("%d %d",&a,&b);
		
		int i,sum = 0;
		for(i = a;i <= b; i++){
			if(isBea(i)) 
				sum++;
		}
		printf("%d\n",sum);
	}
}

Double click to view unformatted code.


Back to problem 3594