codeforces-365A.Good Number记录

A. Good Number
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ≤ 1000 ≤ 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

//error原因1.题意理解错误,只要包括了不超过K的全部数字的数都可以;2代码编写不严谨3.使用了cin、cout
//代码如下
#include<cstdio>
#include<cstring>
int main()
{
	int n,k,cnt=0;
	int s[10];
	scanf("%d%d",&n,&k);
	int j,p;	
	for(int i = 0;i < n;i++)
	{	
		int a;
		memset(s,0,sizeof(s));
		scanf("%d",&a);
		while(a>0)
		{
			p = a % 10;
			if(p<=k)
			{
				s[p]=1;	
			}
			a = a/10;
		}	
		for(j = 0;j<=k;j++)
		{
			if(s[j] == 0)break;
		}
		if(j>k)cnt++;
	}
	printf("%d",cnt);
	return 0 ;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值