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
0 题目说的是,求两个素数的和还为素数的对数,并把符合条件的写下来。
因为大于2的素数都为奇数,所以两奇数和为偶数一定不是素数。剩下的就只有2和其他素数相加。
这样就转换为有多少个差为2的素数。
#include#include #include #include #include #include #include #include #include #include #include