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 这个时候,判断两 ...
随机推荐
- 【BZOJ 3675】[Apio2014]序列分割
[链接] 链接 [题意] 在这里输入题意 [题解] 模拟一下样例. 会发现.切的顺序不影响最后的答案. 只要切点确定了. 答案就确定了. 则设f[i][j]表示前i段,第i段保留到j的最大值. \(f ...
- [TypeScript] Understand lookup types in TypeScript
Lookup types, introduced in TypeScript 2.1, allow us to dynamically create types based on the proper ...
- ios开发网络学习AFN框架的使用一:get和post请求
#import "ViewController.h" #import "AFNetworking.h" @interface ViewController () ...
- php实现 合唱队形(算法想清楚在动)
php实现 合唱队形(算法想清楚在动) 一.总结 一句话总结:写一个最长递增子序列的函数,正反两遍扫一下就好.写函数这样不容易错.这个好像可以用二分来优化. 1.算法题怎么提高正确率和节约时间? 算 ...
- 11G、12C安装结束需要做的一些操作
修改spfile参数:修改前,先备份 create pfile from spfile; alter system set memory_target=0 scope=spfile;alter sys ...
- php正则表达式函数
$zz = '/^\d{1,}$/'; //上面的这种方式没问题,还有一种方式经测试也没问题,如下 echo preg_match($zz, "123423423423");//比 ...
- Android SqlDelight具体解释和Demo样例
一.简单介绍 SQLDelight 和 SqlBrite 是 Square 公司推出的一个 Android 平台数据库解决方式. 在了解这个两个东西前,必须先得有Andorid的Sqlite的知识(S ...
- [TypeScript] Catch unsafe use of "this" in TypeScript functions
this is probably the most tricky thing to use in JavaScript and therefore TypeScript. Fortunately th ...
- 【codeforces 757C】Felicity is Coming!
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Tokumx vs Mongodb
Mongodb是一个文档型nosql数据库 採用C++编写 Mongo DB最大的优势在于全部的数据持久操作都无需开发者手动编写SQL语句,直接调用方法就能够轻松的实现CRUD操作. 非常多人觉得mo ...