zoukankan      html  css  js  c++  java
  • 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;
    }
    


     

  • 相关阅读:
    日志模块
    DDT数据驱动
    unittest测试框架
    vim编辑器
    文件夹的管理
    文件内容查看(如查看日志)
    文件的移动和拷贝
    文件的增删改查
    linux基本命令
    测试5--模拟一个在控制台不断按时分秒打印的电子表
  • 原文地址:https://www.cnblogs.com/riasky/p/3433132.html
Copyright © 2011-2022 走看看