【ECJTU_ACM 11级队员2012年暑假训练赛(8) - I - Lucky Division】

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

ECJTU_ACM 11级队员2012年暑假训练赛(8)
4:30:00
 
 
A  B  C  D  E  F  G  H  I  J  K
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 

转载于:https://www.cnblogs.com/ismdeep/archive/2012/08/13/2635990.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值