-
Notifications
You must be signed in to change notification settings - Fork 0
/
26-Lucky Division.cpp
65 lines (53 loc) · 940 Bytes
/
26-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
55
56
57
58
59
60
61
62
63
64
65
/*
* 26-Lucky Division
* Link: https://vjudge.net/problem/CodeForces-122A
*/
#include <bits/stdc++.h>
using namespace std;
bool is_lucky (int x)
{
stringstream n;
n << x;
bool isLucky;
for (int i = 0; i < n.str().length(); i++)
{
int j = x%10;
if (j == 7 || j == 4)
isLucky = true;
else
{
isLucky = false;
break;
}
x /=10;
}
return isLucky;
}
int main ()
{
int x;
bool checked{0};
cin >> x;
if (is_lucky(x))
{
cout <<"YES";
}
else
{
for (int i = 1; i <= x; i++)
{
int p = x % i;
if (p == 0)
{
checked = is_lucky(i);
}
if (checked)
{
cout << "YES";
break;
}
}
if (!checked) cout << "NO";
}
return 0;
}