Codeforces Round #160 (Div. 2)---A. Roma and Lucky Numbers
1 second
256 megabytes
standard input
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.
The first line contains two integers n, k (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.
In a single line print a single integer — the answer to the problem.
3 4
1 2 4
3
3 2
447 44 77
2
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的更多相关文章
- Codeforces Round #160 (Div. 1) 题解【ABCD】
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...
- 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...
- Codeforces Round #160 (Div. 2)
A. Roma and Lucky Numbers 暴力计算. B. Roma and Changing Signs 每次取最小值改变正负,优先队列维护. C. Maxim and Discounts ...
- Codeforces Round #160 (Div. 2) D. Maxim and Restaurant(DP)
题目链接 想了挺久,枚举每一件物品,当做关键物品,假设再加这一件物品,就>=c了,把剩下的物品背一下包,dp[i][j]表示i个物品可以组成重量j的个数. 这样就可以知道前面放i件,后边肯定放n ...
- 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 ...
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers
题目:http://codeforces.com/contest/397/problem/B 题意:给一个n ,求能不能在[l, r]的区间内的数字相加得到, 数字可多次重复.. 比赛的时候没有想出来 ...
- 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 ...
- Codeforces Round #226 (Div. 2)C. Bear and Prime Numbers
/* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数. */ #include <stdio.h ...
- 【Codeforces Round #452 (Div. 2) C】 Dividing the numbers
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] n为偶数. l = 1, r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两 ...
随机推荐
- HDU 1069 Monkey and Banana DP LIS
http://acm.hdu.edu.cn/showproblem.php?pid=1069 题目大意 一群研究员在研究猴子的智商(T T禽兽啊,欺负猴子!!!),他们决定在房顶放一串香蕉,并且给猴子 ...
- 【69.77%】【codeforces 723A】The New Year: Meeting Friends
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- swift学习第八天:元组
元组的介绍 元组是Swift中特有的,OC中并没有相关类型 它是什么呢? 它是一种数据结构,在数学中应用广泛 类似于数组或者字典 可以用于定义一组数据 组成元组类型的数据可以称为“元素” 元组的定义 ...
- js进阶 11-16 jquery如何查找元素的父亲、祖先和子代、后代
js进阶 11-16 jquery如何查找元素的父亲.祖先和子代.后代 一.总结 一句话总结:过滤或者查找的方法里面可以带参数进行进一步的选择. 1.parent()和parents()方法的区别是什 ...
- 证明的手段 —— 不失一般性的(WLOG)
不失一般性是数学中一个常见的表达.不失一般性(Without loss of generality,缩写:WLOG.WOLOG 或 w.l.o.g.)是数学中一个常见的表达. 如果给不相等的两数,a, ...
- Oracle 12C R2 on Linux 7.X 单实例静默安装文档
禁用防火墙systemctl stop firewalld.servicesystemctl disable firewalld.service 禁用SELinuxcat /etc/selinux/c ...
- USB 3.0规范中译本 第4章 超高速数据流模型
本文为CoryXie原创译文,转载及有任何问题请联系cory.xie#gmail.com. 本章展示数据和信息如何在超高速上通过的一种高层次的描述.请阅读协议层一章关于低层次协议的细节.本章提供设备架 ...
- Haproxy解析
简单介绍 HAProxy是一款提供高可用性.负载均衡以及基于TCP和HTTP应用的代理软件,HAProxy是全然免费的.借助HAProxy能够高速而且可靠的提供基于TCP和HTTP应用的代理解决方式. ...
- Spring学习笔记之六(数据源的配置)
1.前言 上一篇博客分析了,Spring中实现AOP的两种动态代理的机制,以下这篇博客.来解说一下Spring中的数据源的配置. 2.DAO支持的模板类 Spring提供了非常多关于Dao支持的模板 ...
- WM_NOTIFY消息流程实例分析
我们以CListCtrl控件为例来分析WM_NOTIFY消息. CListCtrl控件在Report样式下会包含CHeaderCtrl标头控件,即CHeaderCtrl标头控件为CListCtrl控件 ...