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. Python 细节与基础拾遗

    locals():当前环境下的全部局部变量,字典(dict)类型,所有的 key 均为字符串类型: if 'sess' in locals() and sess is not None: print( ...

  2. iOS开发RunLoop学习:四:RunLoop的应用和RunLoop的面试题

    一:RunLoop的应用 #import "ViewController.h" @interface ViewController () /** 注释 */ @property ( ...

  3. spring(3)------控制反转(IOC)/依赖注入(DI)

    一.spring核心概念理解 控制反转: 控制反转即IoC (Inversion of Control).它把传统上由程序代码直接操控的对象的调用权交给容器.通过容器来实现对象组件的装配和管理. 所谓 ...

  4. GoJS超详细入门(插件使用无非:引包、初始化、配参数(json)、引数据(json)四步)

    GoJS超详细入门(插件使用无非:引包.初始化.配参数(json).引数据(json)四步) 一.总结 一句话总结:插件使用无非:引包.初始化.配参数(json).引数据(json)四步. 1.goj ...

  5. php实现把二叉树打印成多行(谋而后动,写好算法思路,不然浪费超多时间而且还是错误代码,而且精力消耗会导致代码正确率下降以及低级错误)

    php实现把二叉树打印成多行(谋而后动,写好算法思路,不然浪费超多时间而且还是错误代码,而且精力消耗会导致代码正确率下降以及低级错误) 一.总结 要点:a.层次遍历(队列)  b.层次遍历中的层次(孩 ...

  6. JMS是一种应用于异步消息传递的标准API

    JMS是一种应用于异步消息传递的标准API,作为Java平台的一部分,JMS可以允许不同应用.不同模块之间实现可靠.异步数据通信.一些概念 JMS provider    An implementat ...

  7. [Compose] 18. Maintaining structure whilst asyncing

    We take our Promise.all() analogy further by using traversable on a Map(). Then we use two traversal ...

  8. Django之文章归档

    1.任务描述:将博文按照时间月份归档 2.源代码: views.py def getPage(request, article_list): paginator = Paginator(article ...

  9. new File(String Path)加载资源问题

    2017-12-17   15:07:38  [原创-wx] 一.我们在用IO流加载资源的时候,创建文件资源 1 File file = New File("String Path" ...

  10. java类中属性优先执行顺序

    1.父类静态代码块 (  java虚拟机加载类时,就会执行该块代码,故只执行一次) 2 .子类静态代码块 (  java虚拟机加载类时,就会执行该块代码,故只执行一次) 3. 父类属性对象初始化 4. ...