Codeforce Round #213 Div2 A
A. Good Number
time limit per test 1 second
memory limit per test 256 megabytes
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
1 #include <cstdio> 2 #include <vector> 3 #include <queue> 4 #include <cmath> 5 #include <cstring> 6 #include <algorithm> 7 using namespace std; 8 #define maxn 10001 9 #define INF 1000000000 10 #define ll long long 11 char s[maxn]; 12 int a[maxn]; 13 int vis[maxn]; 14 ll gcd(ll n, ll m){ return m ? gcd(m, n%m) : n; } 15 ll n, m, b, c, d, p,t1, t2, cnt1, cnt2, add, sub,ans; 16 int main(){ 17 int t, cas = 1; 18 scanf("%d%d", &n,&m); 19 ans = 0; 20 while (n--){ 21 scanf("%s", s); 22 memset(vis, 0, sizeof vis); 23 int i; 24 for (i = 0; i < strlen(s)-1; i++)if (s[i] != '0')break; 25 for (i = 0; i < strlen(s); i++){ 26 vis[s[i] - '0'] = 1; 27 } 28 t = 0; 29 for (int i = 0; i <=m; i++)if (vis[i])t++; 30 if (t == m+1)ans++; 31 } 32 printf("%d\n", ans); 33 return 0; 34 }
浙公网安备 33010602011771号