codeforces 365A――Good Number

2014-11-24 02:32:48 · 作者: · 浏览: 1
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  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
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