Solve of UVA 12527: Different Digits
#include<iostream>
#include<stdio.h>
using namespace std;
int arr[5005]={0};
int mx=5005;
int dil(int n)
{
int a,i,j,ari[12]={0};
while(n)
{
ari[n%10]++;
if(ari[n%10] > 1)
return 3;
n/=10;
}
return 2;
}
void cid()
{
int n,i,j,k;
for(i=1;i<mx;i++)
{
if(dil(i)==2)
arr[i]=1;
}
}
int main()
{
cid();
int a,b,i,j,k;
while(scanf("%d%d",&a,&b)==2)
{
k=0;
for(i=a;i<=b;i++)
{
k+=arr[i];
}
cout<<k<<endl;
}
return 0;
}
No comments:
Post a Comment