Analysis of Pat computer questions in Zhejiang University 1007. Prime Number pair conjecture (20)

Source: Internet
Author: User
1007. Conjecture of prime number pairs (20) Time Limit 400 MS
Memory limit 32000 KB
CodeLength limit 8000 B
JudgementProgram Standard Author Chen, Yue

Let's define DN as: DN = pN + 1-PN, where Pi is the I prime number. Obviously, d1 = 1 and for n> 1, dn is an even number. The "prime number pair conjecture" considers "There are infinite numbers of adjacent prime numbers with a difference of 2 ".

Given any positive integer N (<105), calculate the number of prime number pairs that do not exceed n.

Input Format:Each test input contains one test case and a positive integer n.

Output Format:The output of each test case occupies one row. The number of prime number pairs that meet the conjecture cannot exceed n.

Input example:

 
20

Output example:

 
4
 
 # include 
   
     # include 
    
      # include 
     
       # include 
      
        # define maxsize 100000 using namespace STD; int prime [maxsize]; int main () {memset (Prime, 0, maxsize); int N, I, j; int K = 0; vector 
       
         VEC; vector 
        
         : iterator it1, it2; int M = (INT) (SQRT (double (maxsize) + 0.5); CIN> N; for (I = 2; I 
          
          

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.