# 13001: 【原3001】二哥的幸运

### 题目描述

author: pigoneand 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/3001

## Sample Input

47


## Sample Output

YES


## satgo1546's solution

#include <iostream>
using namespace std;

bool only47(int x) {
while (x) {
if (x % 10 != 4 && x % 10 != 7) return false;
x /= 10;
}
return true;
}

bool prime(int x) {
if (x < 3) return x == 2;
if (~x & 1) return false;
for (int i = 3; i * i <= x; i += 2) {
if (x % i == 0) return false;
}
return true;
}

int main(int argc, char *argv[]) {
cin >> argc;
cout << (only47(argc) && prime(argc) ? "YES\n" : "NO\n");
return 0;
}


## yyong119's solution

#include <iostream>
#include <cmath>
using namespace std;
int n;
bool flag = true;
int main() {
ios::sync_with_stdio(false);
cin >> n;
int tmp = n;
while (tmp) {
if (tmp % 10 != 7 && tmp % 10 != 4) {
flag = false;
break;
}
tmp /= 10;
}
if (flag)
for (int i = 2; i <= sqrt(n); ++i)
if (n % i == 0) {
flag = false;
break;
}
if (flag) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}