CF17A.Noldbach problem
入门
通过率:0%
时间限制:2.00s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
尼克对质数很感兴趣。他曾读到过哥德巴赫猜想:任一大于 2 的偶数都可以表示为两个质数之和。这引起了尼克的注意,于是他决定自己构造一个问题,并将其命名为“诺尔德巴赫问题”(Noldbach problem)。由于尼克只关心质数,“诺尔德巴赫问题”表述如下:在 2 到 n(含端点)之间的质数中,至少有 k 个质数可以表示为三个整数之和:其中两个是相邻质数,另一个是 1。例如,19=7+11+1,或 13=5+7+1。
若两个质数之间不存在其他质数,则称它们为相邻质数。
你需要帮助尼克判断他的说法是否正确。
输入格式
The first line of the input contains two integers n (2 ≤ n ≤ 1000) and k (0 ≤ k ≤ 1000).
输入的第一行包含两个整数 n(2≤n≤1000)和 k(0≤k≤1000)。
输出格式
Output YES if at least k prime numbers from 2 to n inclusively can be expressed as it was described above. Otherwise output NO.
如果在 2 到 n(含)之间至少有 k 个素数可以按上述方式表示,则输出 YES;否则输出 NO。
输入输出样例
输入#1
27 2
输出#1
YES
输入#2
45 7
输出#2
NO
说明/提示
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.
在第一个样例中,答案为 YES,因为至少有两个数可以按题目描述的方式表示(例如,13 和 19)。在第二个样例中,答案为 NO,因为无法将 2 到 45 之间的 7 个质数全部表示为所要求的形式。
输入解题思路,AI测评打分。不知道怎么写?