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. 配置tomcat通过客户端访问

    1:在tomcat    conf/tomcat-users.xml 文件里  配置用户名和密码,以及访问方式 For example, to add the manager-gui role to ...

  2. 主成分分析 PCA算法原理

    对同一个体进行多项观察时,必定涉及多个随机变量X1,X2,…,Xp,它们都是的相关性, 一时难以综合.这时就需要借助主成分分析 (principal component analysis)来概括诸多信 ...

  3. 安恒X计划12月月赛

    ezweb 主要是序列化问题.没有PHP环境,在线运行的.实例化对象之后修改一下file.然后echo输出序列化的结果.不过下面有一个正则检查.数字前加一个+,影响了正则的匹配,但是对于序列化的还原没 ...

  4. C#实现无标题栏窗体点击任务栏图标正常最小化或还原的解决方法

    对于无标题栏窗体,也就是FormBorderStyle等于System.Windows.Forms.FormBorderStyle.None的窗体,点击任务栏图标的时候,是不能象标准窗体那样最小化或还 ...

  5. Haproxy启动故障:Starting proxy:cannot bind socke

    Haproxy启动时提示失败: [ALERT] 146/132210 (3443) : Starting frontend Redis: cannot bind socket [0.0.0.0:637 ...

  6. 模仿WIN32程序处理消息

    #include "stdafx.h" #include "MyMessage.h" #include <conio.h> using namesp ...

  7. OVS

    基于 OpenvSwitch的OpenFlow实践 Open vSwitch 概述 OpenvSwitch(简称OVS)是由NiciraNetworks主导的,运行在虚拟化平台(例如 KVM,Xen) ...

  8. Hive 中Join的专题---Join详解

    1.什么是等值连接? 2.hive转换多表join时,如果每个表在join字句中,使用的都是同一个列,该如何处理? 3.LEFT,RIGHT,FULL OUTER连接的作用是什么? 4.LEFT或RI ...

  9. linux常用命令:traceroute 命令

    通过traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径.当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不一 ...

  10. jboos下载地址记录

    JBoss在2006年被 RedHat 收购.在各种 J2EE 应用服务器中,JBoss 是最受欢迎而且功能最为强大的应用服务器.不过JBoss从8.0开始改名为WildFly,这个新名称在我看来似乎 ...