A. Noldbach problem

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.

Examples
input
27 2
output
YES
input
45 7
output
NO
Note

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.

题意:问2到n间有多少个素数为两个相邻素数相加加一;

思路:暴力就好了

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
#define true ture
#define false flase
using namespace std;
#define ll __int64
#define inf 0xfffffff
int scan()
{
int res = , ch ;
while( !( ( ch = getchar() ) >= '' && ch <= '' ) )
{
if( ch == EOF ) return << ;
}
res = ch - '' ;
while( ( ch = getchar() ) >= '' && ch <= '' )
res = res * + ( ch - '' ) ;
return res ;
}
int p[],flag[];
int prime(int n)
{
if(n<=)
return ;
if(n==)
return ;
if(n%==)
return ;
int k, upperBound=n/;
for(k=; k<=upperBound; k+=)
{
upperBound=n/k;
if(n%k==)
return ;
}
return ;
}
int main()
{
int ji=;
for(int i=;i<=;i++)
{
if(prime(i))
p[ji++]=i;
}
for(int i=;i<ji;i++)
{
int gg=p[i]+p[i-]+;
if(prime(gg))
flag[gg]=;
}
int x,y;
int ans=;
scanf("%d%d",&x,&y);
for(int i=;i<=x;i++)
if(flag[i])
ans++;
if(ans>=y)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}

Codeforces Beta Round #17 A.素数相关的更多相关文章

  1. Codeforces Beta Round #17 D. Notepad (数论 + 广义欧拉定理降幂)

    Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2 ...

  2. Codeforces Beta Round #17 A - Noldbach problem 暴力

    A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...

  3. Codeforces Beta Round #17 C. Balance DP

    C. Balance 题目链接 http://codeforces.com/contest/17/problem/C 题面 Nick likes strings very much, he likes ...

  4. Codeforces Beta Round #17 C. Balance (字符串计数 dp)

    C. Balance time limit per test 3 seconds memory limit per test 128 megabytes input standard input ou ...

  5. Codeforces Beta Round #17 D.Notepad 指数循环节

    D. Notepad time limit per test 2 seconds memory limit per test 64 megabytes input standard input out ...

  6. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  7. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  8. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  9. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

随机推荐

  1. 最新可靠好用的DNS服务器地址汇总

    如果修改DNS服务器地址就可以访问google等服务,你还等什么?使用免费DNS解析服务除了去掉了运营商的各种广告,还有个最大的好处就是不会重定向或者过滤用户所访问的地址,这样就防止了很多网站被电信. ...

  2. MVC左边导航,左边内容变,通过AJAX方法实现

    前台: @{ ViewBag.Title = "爱湛师-个人信息"; Layout = "~/Views/Shared/DefaultMaster.cshtml" ...

  3. Javascript--普通函数调用-涨工资计算函数

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. http-equiv制作跳转欢迎页面

    做网站嘛,没有个欢迎页面肿么能忍? 要忽悠下浏览者的嘛. 然后此处省略一万字... 目的:不需要其他的脚本,直接在meta中控制时间,跳转页面 原理很简单: < meta http-equiv= ...

  5. Linux基础命令---swapoff

    swapoff 关闭交换分区,同时可以刷新交换分区的缓存.关闭交换分区后,使用free指令查看内存,swap数值会减少.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE. ...

  6. java android 环境变量配置备忘录

    java android 环境变量配置备忘录,全新重装系统要用到,备忘下来; JAVA_HOME D:\Java\jdk1.6.0_07 CLASSPATH  .;%JAVA_HOME%\lib\dt ...

  7. java commons.lang3 ArrayUtils使用

    java commons.lang3 ArrayUtils使用import org.apache.commons.lang3.ArrayUtils; /** *数组追加数组,不重复 */ public ...

  8. MySQL Crash Course #21# Chapter 29.30. Database Maintenance & Improving Performance

    终于结束这本书了,最后两章的内容在官方文档中都有详细介绍,简单过一遍.. 首先是数据备份,最简单直接的就是用 mysql 的内置工具 mysqldump MySQL 8.0 Reference Man ...

  9. python的re正则表达式模块

    元字符  .   *   +   ?   ^   $   { }     [ ]     -     \ .  匹配除了/n之外的任意一个字符 * 匹配*前面的单个字符任意次,即[0,+∞] + 匹配 ...

  10. 基于Android的闹钟的软件

    一.本课题要求:设计一个基于Android的闹钟的软件. 实现的功能有:能通过界面设置闹钟的启动条件建立后台服务进程,当满足触发条件时,闹钟响应相应事件. 二.需求分析 该课题实现在手机操作系统And ...