Test instructions N is equal to two consecutive primes and the number of 1 is less than
#include <cstdio> #include <cmath> #include <algorithm> using namespace std; const int N = +; int N, k, ans; BOOL IsPrime (int a) {for (int i = 2; I <= sqrt (a); ++i) if (a% i = = 0) return 0; return 1; } int main () { int ai = 1, bi = 0, a[n], b[n]; A[1] = 2; for (int i = 3; I <= N; ++i) if (IsPrime (i)) { A[++ai] = i; B[++BI] = A[ai] + a[ai-1] + 1; } scanf ("%d%d", &n, &k); Ans = 0; for (int i = 1; I <= n; ++i) if (IsPrime (i) && find (b + 1, b + bi +, i)! = B + bi + 1) Ans++;
if (ans >= k) printf ("yes\n"); else printf ("no\n"); return 0; }
Nick is interested in prime numbers. Once he read aboutGoldbach Problem. It states that every even integer greater than2Can be expressed as the sum of the primes. That got Nick's attention and he decided to invent a problem of his own and call itNoldbach Problem. Since Nick is interested only in prime numbers, Noldbach problem states so at leastkPrime numbers from2ToNInclusively can be expressed as the sum of three integer numbers:two neighboring prime numbers and1. For example, +=7+ One+1, or -=5+7+1.
The prime numbers is called neighboring if there is no other prime numbers between them.
You were to help Nick, and find out if he was right or wrong.
Input
The first line of the input contains the integers n (2?≤? N? ≤?1000) and K (0?≤? K. ≤?1000).
Output
Output YES If at least K prime numbers from 2 to n inclusively can be expressed as it was described above. Otherwise output NO.
Sample Test (s)input
27 2
Output
YES
input
45 7
Output
NO
Note
In the first sample of the answer is YES since at least-numbers can be expressed as it's described (for Exampl E, and 19). In the second sample of the answer is NO since it's impossible to express 7 prime numbers from 2 to $ in the Desir Ed form.
Codeforces 17A Noldbach problem (mathematics)