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 
  • 相关阅读:
    Gridview如何用自定义按钮进行编辑和提交修改
    winform多线程中给datagridview绑定数据源
    DevExpress控件WebchartControl的学习记录
    datagridview右键选中单元格并获取到焦点
    asp.net局部页面打印,以及如何去掉打印时自动保留的URL地址(页眉页脚)
    GridView如何实现点击某行的指定列弹出新窗体
    C# Color Font 与String之间的转换
    推荐一款 asp.net js日历控件
    js浮点运算替代函数
    VSeWss 1.3 CTP 安装后出现错误
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2635990.html
Copyright © 2011-2022 走看看