-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCHFPRMS.cpp
executable file
·58 lines (52 loc) · 943 Bytes
/
CHFPRMS.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
#include <bits/stdc++.h>
using namespace std;
vector<bool> prime(201, true), semiprime(201, false);
void sieve() {
prime[0] = prime[1] = false;
for (int i = 2; i * i <= 200; i++) {
if (prime[i]) {
for (int j = i * i; j <= 200; j += i)
prime[j] = false;
}
}
}
void semiPrimes() {
sieve();
for (int i = 6; i <= 200; i++) {
for (int j = 2; j <= (i / 2); j++) {
if (i % j == 0 && prime[j]) {
int b = i / j;
if (i % b == 0 && prime[b] && j != b) {
semiprime[i] = true;
break;
}
}
}
}
}
void solve() {
int n;
cin >> n;
semiPrimes();
for (int i = 1; i <= n; i++) {
int a = i, b = n - i;
if (semiprime[a] && semiprime[b]) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
cin >> t;
while (t--)
solve();
return 0;
}