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


     

  • 相关阅读:
    在Spring 中如果Girl要Kiss Boy咋办捏?
    对象的序列化
    HibernateHQL
    Struts 动态FORM实现过程
    对struts一点理解总结
    Hibernate Query Language(HQL)。
    Hibernate中Inverse和Cascade
    Spring 中的内部bean 和集合
    设计模式到底离我们有多远
    Aspx页面转静态页面
  • 原文地址:https://www.cnblogs.com/riasky/p/3433132.html
Copyright © 2020-2023  润新知