-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Lucky_Division.cpp
54 lines (49 loc) · 1014 Bytes
/
A_Lucky_Division.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string str =to_string(n);
int k=0,s = str.size();
if(n%4==0 || n%7==0){
cout<<"YES"<<endl;
}
else{
for(char c:str){
if(c == '7' || c == '4')k++;
}
if(k==s)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
*/
#include <bits/stdc++.h>
using namespace std;
bool isLucky(int num) {
while (num > 0) {
int digit = num % 10;
if (digit != 4 && digit != 7) {
return false;
}
num /= 10;
}
return true;
}
int main() {
int n;
cin >> n;
bool almostLucky = false;
for (int i = 1; i <= 1000; ++i) {
if (isLucky(i) && n % i == 0) {
almostLucky = true;
break;
}
}
if (almostLucky) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}