A. Good Number
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard outputLet'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 61234560123456012345601234560123456012345601234560 1234560 1234560 1234560
output
10
input
2 1110
output
1
///http://codeforces.com/contest/365/problem/A
#include <iostream>
using namespace std;
int main()
{
int n,k,a,b;
while(cin>>n>>k&&n!=0)
{
int c=0;//记录个数,切记初始化
for(int i=0;i<n;i++)
{
cin>>a;
b=0;
while(a)
{
if(a%10<=k)b|=1<<a%10; //b=b|(1<<(a%10));位运算
a/=10;
}
if(b+1==2<<k) c++; //2<<k=10000000,如果0...k的值都存在则b=11111111 ,b+1=10000000
}
cout<<c<<endl;
}
}