zoukankan      html  css  js  c++  java
  • 【ECJTU_ACM 11级队员2012年暑假训练赛(8) G Nearly Lucky Number】

    B题要套一个数论的模版,注意m=1!! C题可以二分匹配,把行列看作点; 不能开百度,开谷歌搜题解,再次强调!一经发现,取消成绩!

    ECJTU_ACM 11级队员2012年暑假训练赛(8)
    4:30:00
     
     
              
    G - Nearly Lucky Number
    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

    Description

    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 477444 are lucky and 517467 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).

    Sample Input

    Input
    40047
    Output
    NO
    Input
    7747774
    Output
    YES
    Input
    1000000000000000000
    Output
    NO

    Hint

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


    FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
    All Copyright Reserved ©2010-2012 HUST ACM/ICPC TEAM 
    Anything about the OJ, please ask in the forum, or contact author:Isun
    Server Time: 2012-08-13 10:52:34
     1 // Project name : G
     2 // File name    : main.cpp
     3 // Author       : iCoding
     4 // E-mail       : honi.linux@gmail.com
     5 // Date & Time  : Fri Aug 10 15:24:28 2012
     6 
     7 
     8 #include <iostream>
     9 #include <stdio.h>
    10 #include <string>
    11 #include <cmath>
    12 #include <algorithm>
    13 using namespace std;
    14 
    15 /*************************************************************************************/
    16 /* data */
    17 
    18 
    19 /*************************************************************************************/
    20 /* procedure */
    21 
    22 
    23 /*************************************************************************************/
    24 /* main */
    25 int main()
    26 {
    27     string s;
    28     while (cin >> s)
    29     {
    30         int count = 0;
    31         int top = s.length() - 1;
    32         for (int i = 0; i <= top; i++)
    33         {
    34             if (s[i] == '4' || s[i] == '7')
    35             {
    36                 count++;
    37             }
    38         }
    39 
    40         //cout << count << endl;
    41 
    42         bool yes = true;
    43         if (count == 0)
    44         {
    45             yes = false;
    46         }
    47         while (yes == true && count)
    48         {
    49             if (count % 10 == 4 || count % 10 == 7)
    50             {
    51                 count /= 10;
    52             }
    53             else
    54             {
    55                 yes = false;
    56             }
    57         }
    58 
    59         if (yes)
    60         {
    61             cout << "YES" << endl;
    62         }
    63         else
    64         {
    65             cout << "NO"  << endl;
    66         }
    67     }
    68     return 0;
    69 }
    70 
    71 // end 
    72 // Code by Sublime text 2
    73 // iCoding@CodeLab 
  • 相关阅读:
    pillow模块的用法 + 随机验证码
    jquery文件阅读器 显示需要上传图片的预览功能
    pycharm永久激活方式
    pycharm汉化
    10.25网络编程到并发编程
    10.15 迭代器,生成器到常用模块的小结
    10.14 面向对象小结
    十一天学习内容总结大纲
    pip镜像源的替换
    前端jQuery导入方式
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2635983.html
Copyright © 2011-2022 走看看