A. Roma and Lucky Numbers

来源:互联网 发布:linux c 编译器下载 编辑:程序博客网 时间:2024/05/21 06:11

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.

Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 477444 are lucky and 517467 are not.

Roma's got n positive integers. He wonders, how many of those integers have not more than k lucky digits? Help him, write the program that solves the problem.

Input

The first line contains two integers nk (1 ≤ n, k ≤ 100). The second line contains n integers ai (1 ≤ ai ≤ 109) — the numbers that Roma has.

The numbers in the lines are separated by single spaces.

Output

In a single line print a single integer — the answer to the problem.

Sample test(s)
input
3 41 2 4
output
3
input
3 2447 44 77
output
2
Note

In the first sample all numbers contain at most four lucky digits, so the answer is 3.

In the second sample number 447 doesn't fit in, as it contains more than two lucky digits. All other numbers are fine, so the answer is 2.



解题说明:此题就是存储问题,可以转换为字符数组形式进行存储


#include<cstdio>#include<iostream>#include<cstring>#include<cmath>using namespace std;int main(){int n,k;int i,j;int length;int sum;int count,cn;char s[100][12];scanf("%d %d",&n,&k);for(i=0;i<n;i++){scanf("%s",&s[i]);}count=0;for(i=0;i<n;i++){length=strlen(s[i]);cn=0;for(j=0;j<length;j++){if(s[i][j]=='4'||s[i][j]=='7'){cn++;}}if(cn<=k){count++;}}printf("%d\n",count);return 0;}