codeforces 365A——Good Number

Let's call a number k-good if it contains all digits not exceedingk (0, ..., k). You've got a numberk and an array a containingn numbers. Find out how many k-good numbers are in a (count each number every time it occurs in arraya).

Input

The first line contains integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 9). The i-th of the followingn lines contains integer ai without leading zeroes (1 ≤ ai ≤ 109).

Output

Print a single integer — the number of k-good numbers ina.

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
 
 
分析:
第一次做CF的题目==
 
昨天晚上饶有兴致、故搞起,乍看题目,看完第一组样例以为是求每个数,每个数中的 数字都比K小、我以为找这样的数……然后敲着代码感觉不对劲,第二组样例不对,于是 这是怎么看也看不懂题目了。。今天继续看了看,提交没过,看了看测试样例(CF居然 能看测试样例!好给力有木有!),才恍然大悟!其实,这就是一个水。。。。。
 
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
bool f(int n,int k)
{
    int p;
    int f=0,t=0;
    char s[10];
    memset(s,0,sizeof(s));
    while(n)
    {
        p=n%10;
        s[p]=1;
        n/=10;
    }
    for(int i=0; i<=k; i++)
    {
        if(s[i]==0)
        {
            f=1;
            break;
        }
    }
    if(f==0)
        return true;
    else
        return false;
}
int main()
{
    int n,k,w;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        int count=0;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&w);
            if(f(w,k))
                count++;
        }
        printf("%d\n",count);
    }
    return 0;
}

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值