Codeforces Lucky Division
//Next Codeforces Round #354 (Div. 2)
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
//#define i64 long long
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
bool digitcheck(int n)
{
while(n)
{
if(n % 10 != 4)
{
if(n % 10 != 7)
{
return false;
}
}
n/=10;
}
return true;
}
bool productcheck(int n)
{
if(n % 4 == 0) return true;
else if(n % 7 == 0) return true;
else if(n % 47 == 0) return true;
else if(n % 74 == 0) return true;
else if(n % 447 == 0) return true;
else if(n % 774 == 0) return true;
else return false;
}
int main()
{
fast;
int n;
while(cin >> n)
{
int tmp = n;
//bool f=digitcheck(tmp);
//cout << f;
if(digitcheck(tmp) or productcheck(n))
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
}
return 0;
}
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
//#define i64 long long
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
bool digitcheck(int n)
{
while(n)
{
if(n % 10 != 4)
{
if(n % 10 != 7)
{
return false;
}
}
n/=10;
}
return true;
}
bool productcheck(int n)
{
if(n % 4 == 0) return true;
else if(n % 7 == 0) return true;
else if(n % 47 == 0) return true;
else if(n % 74 == 0) return true;
else if(n % 447 == 0) return true;
else if(n % 774 == 0) return true;
else return false;
}
int main()
{
fast;
int n;
while(cin >> n)
{
int tmp = n;
//bool f=digitcheck(tmp);
//cout << f;
if(digitcheck(tmp) or productcheck(n))
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
}
return 0;
}
Comments
Post a Comment