## 丙三醇

Stupid boy learn programming . QQ交流：792883735

# SGU231-Prime Sum 还是素数

#### 231. Prime Sum

time limit per test: 0.5 sec.
memory limit per test: 4096 KB
input: standard
output: standard

Find all pairs of prime numbers (A, B) such that A<=B and their sum is also a prime number and does not exceed N.

Input
The input of the problem consists of the only integer N (1<=N<=10^6).

Output
On the first line of the output file write the number of pairs meeting the requirements. Then output all pairs one per line (two primes separated by a space).

Sample test(s)

Input

4
Output

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
bool vis[1000007];
void isprime(int n)
{
int k=sqrt(n+0.5);
for(int i=2; i<=k; i++)
{
if(!vis[i])
for(int j=i*i; j<=n; j+=i)
vis[j]=1;
}
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(vis,0,sizeof(vis));
vis[0]=1,vis[1]=1;
int count=0;
isprime(n);
for(int i=2; i<=n-2; i++)
{
if(!vis[i]&&!vis[i+2]&&(i+2)<=n)
count++;
}
printf("%d\n",count);
if(count)
{
for(int i=2; i<=n-2; i++)
{
if(!vis[i]&&!vis[i+2]&&(i+2)<=n)
printf("2 %d\n",i);
}
}
}
return 0;
}


#### 欧拉项目010:2000000以内的素数和

2014-05-23 10:29:46

#### LINTCODE——判断k个素数之和

2017-11-22 09:25:25

#### 南邮 OJ 1954 三位数素数判断

2015-08-07 10:15:59

#### 纯素数(easy)

2017-01-11 15:33:51

#### CQUOJ F. 神秘的超级素数

2016-04-04 10:45:41

#### 求100以内的所有素数 和 求前100个素数

2014-05-13 13:31:26

#### 素数和回文数

2017-11-19 20:14:43

#### 中国大学慕课C语言第六讲作业

2017-05-27 21:54:49

#### vb程序求出100以内素数的和

2012-04-19 17:33:30

#### 【HUSTOJ】1104: 纯粹素数

2016-05-11 15:45:43