A. Good Number
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Sample test(s)
input
10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560
output
10
input
2 1 1 10
output
1
//error原因1.题意理解错误,只要包括了不超过K的全部数字的数都可以;2代码编写不严谨3.使用了cin、cout
//代码如下
#include<cstdio>
#include<cstring>
int main()
{
int n,k,cnt=0;
int s[10];
scanf("%d%d",&n,&k);
int j,p;
for(int i = 0;i < n;i++)
{
int a;
memset(s,0,sizeof(s));
scanf("%d",&a);
while(a>0)
{
p = a % 10;
if(p<=k)
{
s[p]=1;
}
a = a/10;
}
for(j = 0;j<=k;j++)
{
if(s[j] == 0)break;
}
if(j>k)cnt++;
}
printf("%d",cnt);
return 0 ;
}