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)