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
题意:给出n和k,找出n个数中含有0~k这些数字的数有几个
水题,一开始没理解题意,真坑
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int main() { int n,k,i,ans,j; char str[1000]; while(~scanf("%d%d",&n,&k)) { ans = 0; for(i = 1;i<=n;i++) { scanf("%s",str); int len = strlen(str); int cnt = 0; for(j = 0;j<=k;j++) { char s[10]; s[0] = j+'0'; s[1] = ' '; if(!strstr(str,s)) break; } if(j>k) ans++; } printf("%d ",ans); } return 0; }