-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path17A.cpp
More file actions
53 lines (43 loc) · 961 Bytes
/
Copy path17A.cpp
File metadata and controls
53 lines (43 loc) · 961 Bytes
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
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long
#define umap unordered_map
#define f(i, x, n) for (ll i = x; i < n; i++)
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool isPrime(ll num) {
if (num <= 1) return false;
if (num <= 3) return true;
if (num % 2 == 0 || num % 3 == 0) return false;
for (int i = 5; i * i <= num; i += 6) {
if (num % i == 0 || num % (i + 2) == 0)
return false;
}
return true;
}
int main() {
optimize();
ll n, k; cin >> n >> k;
vector<ll> v;
unordered_map<ll, bool> m;
for (ll i = 2; i <= n; i++) {
if (isPrime(i)) {
v.pb(i);
m[i] = false;
}
}
ll cnt = 0;
for (ll i = 0; i < v.size()-1; i++) {
if (m.count(v[i]+v[i+1]+1)) {
cnt++;
}
if (cnt >= k) break;
}
if (cnt >= k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}