Nearly Lucky Number

简介: Nearly Lucky Number

文章目录

一、Nearly Lucky Number

总结


一、Nearly Lucky Number

本题链接:Nearly Lucky Number


题目:


A. Nearly Lucky Number

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 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 number n is a nearly lucky number.


Input

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.


Output

Print on the single line “YES” if n is a nearly lucky number. Otherwise, print “NO” (without the quotes).


Examples


input

40047

output

NO


input

7747774

output

YES


input

1000000000000000000

output

NO


Note

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”.


本博客给出本题截图:

image.png

题意:有数字7和数字4就是幸运数字,如果一个数中幸运数字的数为74的话这个数就是近似幸运数字,如果一个数是近似幸运数字的话就输出YES,反之输出NO

AC代码

#include <iostream>
#include <string>
using namespace std;
int main()
{
  string a;
  cin >> a;
  int sum = 0;
  for (int i = 0; i < a.size(); i ++ )
    if (a[i] == '4' || a[i] == '7')
      sum ++; 
  if (sum == 4 || sum == 7) puts("YES");
  else puts("NO");
  return 0;
}

总结

没读清题,以为是输出是否幸运数字,WA了三次

水题,不解释


目录
相关文章
|
12月前
A. Nearly Lucky Number
A. Nearly Lucky Number
37 0
|
5月前
|
算法
Leetcode 313. Super Ugly Number
题目翻译成中文是『超级丑数』,啥叫丑数?丑数就是素因子只有2,3,5的数,7 14 21不是丑数,因为他们都有7这个素数。 这里的超级丑数只是对丑数的一个扩展,超级丑数的素因子不再仅限于2 3 5,而是由题目给定一个素数数组。与朴素丑数算法相比,只是将素因子变了而已,解法还是和朴素丑数一致的。
63 1
|
5月前
|
存储
Leetcode Single Number II (面试题推荐)
给你一个整数数组,每个元素出现了三次,但只有一个元素出现了一次,让你找出这个数,要求线性的时间复杂度,不使用额外空间。
21 0
LeetCode 136. 只出现一次的数字 Single Number
LeetCode 136. 只出现一次的数字 Single Number
LeetCode contest 177 5169. 日期之间隔几天 Number of Days Between Two Dates
LeetCode contest 177 5169. 日期之间隔几天 Number of Days Between Two Dates
|
算法
LeetCode 414. Third Maximum Number
给定一个非空数组,返回此数组中第三大的数。如果不存在,则返回数组中最大的数。要求算法时间复杂度必须是O(n)。
66 0
LeetCode 414. Third Maximum Number
|
存储
LeetCode 313. Super Ugly Number
编写一段程序来查找第 n 个超级丑数。 超级丑数是指其所有质因数都是长度为 k 的质数列表 primes 中的正整数。
64 0
LeetCode 313. Super Ugly Number
|
算法
LeetCode 306. Additive Number
累加数是一个字符串,组成它的数字可以形成累加序列。 一个有效的累加序列必须至少包含 3 个数。除了最开始的两个数以外,字符串中的其他数都等于它之前两个数相加的和。 给定一个只包含数字 '0'-'9' 的字符串,编写一个算法来判断给定输入是否是累加数。 说明: 累加序列里的数不会以 0 开头,所以不会出现 1, 2, 03 或者 1, 02, 3 的情况。
88 0
LeetCode 306. Additive Number
|
算法
LeetCode 268. Missing Number
给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数。
62 0
LeetCode 268. Missing Number
LeetCode 264. Ugly Number II
编写一个程序,找出第 n 个丑数。 丑数就是只包含质因数 2, 3, 5 的正整数。
53 0
LeetCode 264. Ugly Number II