codeforces 110A Nearly Lucky Number
来源:互联网 发布:剑灵捏脸人族萝莉数据 编辑:程序博客网 时间:2024/06/06 14:20
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits4 and 7. For example, numbers47, 744,4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether numbern is a nearly lucky number.
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
40047
NO
7747774
YES
1000000000000000000
NO
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO".
AC:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char p[20];
gets(p);
int sum=0;
int len=strlen(p);
for(int i=0;i<len;i++)
if(p[i]-'4'==0||p[i]-'7'==0)
sum++;
if(sum==4||sum==7)
printf("YES");
else
printf("NO");
}
看懂题意是关键
这是统计4和7的个数是不是4或7
- Codeforces 110A-Nearly Lucky Number(实现)
- CodeForces 110A Nearly Lucky Number
- Problem--110A--Codeforces--Nearly Lucky Number
- codeforces 110A Nearly Lucky Number
- 110A - Nearly Lucky Number
- codeforces 110A(Nearly Lucky Number) Java
- CodeForces 110A Nearly Lucky Number (近似幸运数字)
- CodeForces 110 A.Nearly Lucky Number(水~)
- A. Nearly Lucky Number
- A. Nearly Lucky Number
- CF 110A Nearly Lucky Number
- CodeForces 110A Nearly Lucky N…
- Codeforces刷题之路——110A Nearly Lucky Number
- codefroces 110A Nearly Lucky Number(模拟水题)
- 【string】#84 A. Nearly Lucky Number
- Coderforces Nearly Lucky Number
- 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)
- 【CodeForces】A. Lucky Division
- app性能优化
- 深度学习最全优化方法总结比较(SGD,Adagrad,Adadelta,Adam,Adamax,Nadam)
- Ubuntu下C语言实现贪吃蛇游戏
- Java读取resource文件/路径的几种方式
- dubbo 配置文件详解
- codeforces 110A Nearly Lucky Number
- 关于Alipay支付宝接口(Java版)
- Kotlin-1.4-返回和跳转
- Kaggle-titanic-v0
- 【.NET】两个数据加密算法-DESEncrypt+MD5
- activiti 监听引擎启动和初始化
- Ubuntu 配置JDK 环境变量
- 《Java编程技巧1001条》352条:求数x的n次方的方法pow(x,n)
- nodejs爬虫如何设置动态ip以及userAgent