当前位置: 首页 > 工具软件 > ROMA > 使用案例 >

Codeforces Round #160 (Div. 2) A. Roma and Lucky Numbers

齐志勇
2023-12-01

题目:http://codeforces.com/contest/262/problem/A

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;



int main()
{
    int n,k;
    cin >> n >> k;
    int num;
    int ans=0;
    char digit[10];
    for(int i=0;i<n;i++)
    {
        int counter=0;
        cin >> num;
        int flag=1;
        sprintf(digit,"%d",num);
        int len = strlen(digit);
        for(int j=0;j<len;j++)
        {
            if((digit[j]-'0')==4||(digit[j]-'0')==7)
            {
                counter++;
            }
            if(counter>k) 
            {
                flag=0;
                break;
            }
        }
        if(flag==1) ans++;
    }
    cout << ans <<endl;
    return 0;
}

 

 

转载于:https://www.cnblogs.com/danielqiu/archive/2013/01/16/2862819.html

 类似资料: