###### CodeForces-17A-Noldbach problem

Description

Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick’s attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only in prime numbers, Noldbach problem states that at least k prime numbers from 2 to n inclusively can be expressed as the sum of three integer numbers: two neighboring prime numbers and 1. For example, 19 = 7 + 11 + 1, or 13 = 5 + 7 + 1.

Two prime numbers are called neighboring if there are no other prime numbers between them.

You are to help Nick, and find out if he is right or wrong.

Input

The first line of the input contains two 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 Input
Input

27 2

Output

YES

Input

45 7

Output

NO

Hint

In the first sample the answer is YES since at least two numbers can be expressed as it was described (for example, 13 and 19). In the second sample the answer is NO since it is impossible to express 7 prime numbers from 2 to 45 in the desired form.

#include<bits/stdc++.h>
using namespace std;
const int N = 2222;
int prime[N],pre[N];

bool pri(int num)
{
for(int i=2;i*i<=num;i++)
if(num%i==0) return false;
return true;
}

void init()
{
int i,j,cnt;
for(i=2;i<=1000;i++) {
if(!prime[i])
for(j=i+i;j<=1000;j+=i)
prime[j]=1;
}
cnt=0;
for(i=2;i<=1000;i++) {
if(!prime[i]) prime[++cnt]=i;
}
for(i=2;i<=cnt;i++) {
int t=prime[i]+prime[i-1]+1;
if(pri(t)) pre[t]=1;
}
for(i=1;i<=1000;i++) {
pre[i]+=pre[i-1];

}
}

int main()
{
init();
int n,k;
while(scanf("%d%d",&n,&k)!=EOF)
{
if(pre[n]>=k) printf("YES\n");
else printf("NO\n");
}
return 0;
}



2014-11-03 18:21:00

#### On a problem of formal logic___ramsey___1928

2011年03月11日 1.39MB 下载

#### POJ1321-Chess Problem

2011年07月31日 6KB 下载

#### websphere problem solution

2011年12月15日 3.14MB 下载

#### MCM 2012 problem A B C 论文

2012年02月11日 335KB 下载

#### hutc-Factorial Problem 参考代码

2010年01月05日 363B 下载

#### [leetcode] 218. The Skyline Problem 解题报告

2016-05-04 09:41:29

#### ZOJ Problem Set - 1002（DFS）

2016-02-26 23:39:40

#### Eclipse Tomcat Problem Occurred

2016-02-18 13:36:47

#### 破解密码(原题目：The Hardest Problem Ever)

2014-08-10 11:43:33

## 不良信息举报

CodeForces-17A-Noldbach problem