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 47, 744, 4 are
lucky and 5, 17, 467 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 4
1 2 4
output
3
input
3 2
447 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.

题目大意:脑残呀,開始居然没读懂题意。给出n个数,让你看这么多数中,有多少个是包括不多于k个幸运数字的,当中4和7是幸运数字。

解题思路:直接推断每一个数数否满足情况就好了。

AC代码:

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define INF 0x7fffffff int main()
{
#ifdef sxk
freopen("in.txt","r",stdin);
#endif
int n, k, t;
while(scanf("%d%d",&n,&k)!=EOF)
{
int ans = 0;
for(int i=0; i<n; i++){
scanf("%d", &t);
int cnt = 0;;
while(t){
int x = t%10;
if(x==4 || x==7) cnt ++;
t /= 10;
}
if(cnt <= k) ans ++;
}
printf("%d\n", ans);
}
return 0;
}

Codeforces Round #160 (Div. 2)---A. Roma and Lucky Numbers的更多相关文章

  1. Codeforces Round #160 (Div. 1) 题解【ABCD】

    Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...

  2. 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers

    题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...

  3. Codeforces Round #160 (Div. 2)

    A. Roma and Lucky Numbers 暴力计算. B. Roma and Changing Signs 每次取最小值改变正负,优先队列维护. C. Maxim and Discounts ...

  4. Codeforces Round #160 (Div. 2) D. Maxim and Restaurant(DP)

    题目链接 想了挺久,枚举每一件物品,当做关键物品,假设再加这一件物品,就>=c了,把剩下的物品背一下包,dp[i][j]表示i个物品可以组成重量j的个数. 这样就可以知道前面放i件,后边肯定放n ...

  5. Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题

    B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  6. Codeforces Round #232 (Div. 2) B. On Corruption and Numbers

    题目:http://codeforces.com/contest/397/problem/B 题意:给一个n ,求能不能在[l, r]的区间内的数字相加得到, 数字可多次重复.. 比赛的时候没有想出来 ...

  7. Codeforces Round #FF (Div. 2)__E. DZY Loves Fibonacci Numbers (CF447) 线段树

    http://codeforces.com/contest/447/problem/E 题意: 给定一个数组, m次操作, 1 l r 表示区间修改, 每次 a[i] +  Fibonacci[i-l ...

  8. Codeforces Round #226 (Div. 2)C. Bear and Prime Numbers

    /* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数. */ #include <stdio.h ...

  9. 【Codeforces Round #452 (Div. 2) C】 Dividing the numbers

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] n为偶数. l = 1, r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两 ...

随机推荐

  1. ocx中用自定义消息去调用自定义事件

    硬件发送消息---->接收到消息后调用回调函数DWORD __stdcall CxxxCtrl::FVI_NotifyCallBack(void *FVINOTIFYCallbackCtx,UI ...

  2. js课程 2-7 for-in循环怎么使用

    js课程 2-7 for-in循环怎么使用 一.总结 一句话总结:用的是in的作用加上for的作用,相当于一个组合技. 1.js中in运算符的作用是什么? 判断一个元素是否在一个集合或者对象中 1.a ...

  3. php替换空格(php函数的设计思路)

    php替换空格(php函数的设计思路) 一.总结 1.替换和也是先查找了再替换,截取的话就是先查找到再截取 2.设计函数的时候按照的是缺省参数在后,核心东西在前的思路来设计函数的:查找的话是$sear ...

  4. stm32的dac

  5. ActiveMQ简单入门实例

    一.下载MQ 官方网站下载:http://activemq.apache.org/ 我用的是 apache-activemq-5.15.0-bin 二.安装 我用的是64位所以双击 apache-ac ...

  6. ios开发缓存处理类NSCash类的了解与使用

    一:NSCash的基本了解 #import "ViewController.h" @interface ViewController ()<NSCacheDelegate&g ...

  7. 如何快糙好猛的使用libfacedetection库【最新版】

    前言 最近已经很少看CSDN了.这一年多准备考研,基本上怕是不会再怎么上了.以前有一个http://blog.csdn.net/mr_curry/article/details/51804072 如何 ...

  8. 【u216】A+B Problem(aplusb)

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 对于给定的A和B,求A+B的值. [输入格式] 输入文件aplusb.in的第1行为一个整数A,第2行 ...

  9. Java Math数字处理类与包装类习题

    //创建Integer类对象,并以int型返回 Integer intAb = new Integer("123"); System.out.println(intAb.intVa ...

  10. 输入框改变placeholder字体颜色

    ::-webkit-input-placeholder {  color: red;}:-moz-placeholder {  color: red;}::-moz-placeholder{color ...