Time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Yue
Let's define the DN as: DN = PN+1-PN, where pi is the number I prime. Obviously there are d1=1 and the DN for n>1 is even. "The prime number pairs conjecture" that there are infinitely many pairs of adjacent and the difference is 2 primes.
Now given any positive integer n (< 105), please calculate the number of prime pairs that do not exceed N to satisfy the conjecture.
input Format: each test input contains 1 test cases, giving a positive integer n.
output format: the output of each test case occupies one line, not exceeding N of the number of prime pairs that satisfy the conjecture.
Input Sample:
20
Sample output:
4
#include <stdio.h>#include<math.h>intMain () {intIsPrime =0; intn= -; scanf ("%d",&N); if(n>100000){ return 0; } if(n<5) {printf ("0"); }Else{ for(intI=2; i<=n;i++){ if(Prime (i) && Prime (i)2) ) {IsPrime++; }} printf ("%d", IsPrime); } return 0;}intPrimeintm) { intI,n; if(m==1|| m==0){ return 0; } N=sqrt (m); for(i=2; i<=n;i++){ if(m%i==0){ return 0; } } return 1;}
1007. Prime number pairs conjecture (20)