codeforces-365A.Good Number记录

来源:互联网 发布:传智java视频教程 编辑:程序博客网 时间:2024/04/29 01:12
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 61234560123456012345601234560123456012345601234560123456012345601234560
output
10
input
2 1110
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
原创粉丝点击