Searching for Prime pairs (hd1262)

Source: Internet
Author: User

Looking for prime number pairs

Point Me

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9517 Accepted Submission (s): 4827


Problem description Goldbach Guess we all know a little bit. We're not trying to prove that, but we want to take an even number out of a set of numbers that can be represented within a programming language to find two primes so that they are equal to that even.
By doing this, we can show that this conjecture is set up.
Since there can be different prime pairs to represent the same even number, it is specifically required that the prime pair being searched is the closest of two.

Input inputs are some even integer M (5<m<=10000).

Output for each even number, outputs two prime numbers closest to each other, and equals the even number.

Sample INPUT20 30 40

Sample Output7 1313 1717 23
1#include <iostream>2#include <cstdio>3 using namespacestd;4 intIsPrime (intx)5 {6     inti,k;7      for(i=2; i<=x/2; i++)8     {9         if(x%i==0)Ten              Break; One     } A     if(i== (x/2+1)) -         return 1; -     return 0; the  - } - intMain () - { +     intN; -      while(cin>>N) +     { A         intk=n/2, I; at          for(i=k;i>1; i--) -         { -             if(IsPrime (i) &&isprime (ni)) -             { -cout<<i<<' '<<n-i<<Endl; -                  Break; in             } -         } to     } +}

Searching for Prime pairs (hd1262)

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.