【ECJTU_ACM 11级队员2012年暑假训练赛(8) - I - Lucky Division】
Home | Problems | Status | Contest | Register | Login |
B题要套一个数论的模版,注意m=1!! C题可以二分匹配,把行列看作点; 不能开百度,开谷歌搜题解,再次强调!一经发现,取消成绩!
ECJTU_ACM 11级队员2012年暑假训练赛(8)
4:30:00
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