• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

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 }
View Code
posted @ 2013-11-20 02:19  HaibaraAi  阅读(203)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3