***Good Number***
Let’s call a number k-good if it contains all digits not exceeding k (0, …, k). You’ve got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a).
Input
The first line contains integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≤ ai ≤ 109).
Output
Print a single integer — the number of k-good numbers in a.
Examples
Input
10 6
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
Output
10
Input
2 1
1
10
Output
1
题意:判断一串数字是否含有小于k的所有阿拉伯数字,输出所有符合这种形式的数据个数。
思路:可以对数据不断取余10,和除以10进行循环,直至判断结束。取的余数作为下标存进空数组中,而后对数组进行判断,若下标比k以下的数组不为1,说明该数据不符合规则。而后,对下标进行判断,判断与K+1的关系,等于k+1的时候,该数据满足规则,个数加一。直至循环结束,输出个数。
在这里插入代码片
#include"stdio.h"
#include"string.h"
int main()
{
int n,k,a[15];
while(~scanf("%d %d",&n,&k))
{
long long s;
int j,m;
int sum=0;
for(int i=0;i<n;i++)
{
memset(a,0,sizeof(a));
scanf("%lld",&s);
while(s>0)
{
m=0;
m=s%10;
if(m<=k)
{
a[m]=1;
}
s/=10;
}
for(j=0;j<=k;j++)
{
if(a[j]==0)
{
break;
}
}
if(j==k+1)
{
sum++;
}
}
printf("%d\n",sum);
}
return 0;
}