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

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

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

    Description

    Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 477444 are lucky and 517467 are not.

    Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.

    Input

    The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.

    Output

    In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).

    Sample Input

    Input
    47
    Output
    YES
    Input
    16
    Output
    YES
    Input
    78
    Output
    NO

    Hint

    Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.

    In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.


    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:54:33
     1 // Project name : I ( Lucky Division ) 
     2 // File name    : main.cpp
     3 // Author       : iCoding
     4 // E-mail       : honi.linux@gmail.com
     5 // Date & Time  : Fri Aug 10 12:40:15 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 #define MAXN 2000
    18 bool iIsAlmostLucky[MAXN];
    19 
    20 /*************************************************************************************/
    21 /* procedure */
    22 
    23 bool iIsLucky(int iNum)
    24 {
    25     bool iFlag = true;
    26     while (iNum && iFlag)
    27     {
    28         if (iNum % 10 == 4 || iNum % 10 == 7)
    29         {
    30             iFlag = true;
    31         }
    32         else
    33         {
    34             iFlag = false;
    35         }
    36         iNum /= 10;
    37     }
    38     return iFlag;
    39 }
    40 
    41 void iMakeIsAlmostLucky()
    42 {
    43     iIsAlmostLucky[0] = false;
    44     iIsAlmostLucky[1] = false;
    45 
    46     for (int i = 2; i < MAXN; i++)
    47     {
    48         iIsAlmostLucky[i] = false;
    49     }
    50 
    51     for (int i = 2; i < MAXN; i++)
    52     {
    53         if (iIsLucky(i))
    54         {
    55             for (int j = 1; j * i < MAXN; j++)
    56             {
    57                 iIsAlmostLucky[j*i] = true;
    58             }
    59         }
    60     }
    61 }
    62 
    63 /*************************************************************************************/
    64 /* main */
    65 int main()
    66 {
    67     iMakeIsAlmostLucky();
    68     int n;
    69     while (cin >> n)
    70     {
    71         if (iIsAlmostLucky[n])
    72         {
    73             cout << "YES" << endl;
    74         }
    75         else
    76         {
    77             cout << "NO" << endl;
    78         }
    79     }
    80     return 0;
    81 }
    82 
    83 // end 
    84 // Code by Sublime text 2
    85 // iCoding@CodeLab 
  • 相关阅读:
    oracle数据查询
    jQuery基础
    Oracle数据库基础知识
    Prometheus监控k8s企业级应用
    在kubernetes集群里集成Apollo配置中心(6)之实战使用apollo分环境管理dubbo服务
    在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战
    在kubernetes集群里集成Apollo配置中心(4)之dubbo服务提供者连接apollo实战
    Python 集合
    在kubernetes集群里集成Apollo配置中心(3)之交付Apollo-portal至Kubernetes集群
    在kubernetes集群里集成Apollo配置中心(1)之交付Apollo-adminservice至Kubernetes集群
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2635990.html
Copyright © 2011-2022 走看看