CF#231DIV2:A Good Number

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] = '\0';
                if(!strstr(str,s))
                break;
            }
            if(j>k)
            ans++;
        }
        printf("%d\n",ans);
    }

    return 0;
}


 

 

转载于:https://www.cnblogs.com/riasky/p/3433132.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值