-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
33 lines (32 loc) · 849 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
using namespace std;
bool checkLucky(int x){
if(x < 10 && (x == 4 || x == 7)){
return 1;
}
else if((x > 10 && x < 100) && ((x/10 == 4 || x/10 == 7) && (x%10 == 4 || x%10 ==7))){ //check the first digit and last digit
return 1;
}
else if((x > 100 && x < 1000) && ((x%10 == 7 || x%10 == 4)) && (x/10 == 44 || x/10 == 47 || x/10 == 77 || x/10 == 74) ){ //check first two digits and last digit
return 1;
}
else{
return 0;
}
}
int main()
{
int number;
cin>>number;
string check;
for(int i = 1; i < 1000; i++){
if(checkLucky(i)){
if(number%i == 0){
check = "YES";
}
}
}
if(check == "YES"){cout<<check;}
else{check = "NO"; cout<<check;}
return 0;
}