SNOWPRIM-editorial

PROBLEM LINK:

Practice
Contest

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Math, Prime Numbers

PROBLEM:

Given a number n you need to tell if 2*n can be written as some of two primes.

EXPLANATION:

Observe that 2n will always be an even number. According to the even Goldbach conjecture (Euler, 1742) all even numbers larger than 2 are the sum of two primes. This conjecture is unsolved for all values of n but it is solved for 10^18 or larger. In the problem the range of 2n fits into this range. So for n=1 the output is No else the output is Yes.

AUTHOR’S SOLUTIONS:

Author’s solution can be found here.

Modified the question to ’ & find the prime numbers ’ Then the solution is:-

void main()
{
clrscr();
int n;
cin>>n;
int prime[40];
prime[0]=2;
prime[1]=3;
prime[2]=5;
prime[3]=7;
int flag=0;
int c=4;

for(int i=8;i<2*n;i++)
{
  if((2*n)%i!=0  && i%5!=0 && i%2!=0 && i%7!=0 && i%3!=0)
 {


  prime[c++]=i;

 }
}
c--;
for(i=0; i<c;i++)
{
  for(int j=0;j<c;j++)
  {
	if(prime[i]+prime[j]==2*n)
	cout<<" --> "<<prime[i]<< " + "<< prime[j]<<endl;
  }
}
getch();
}

PS: I have no clue what Code Chef is Displaying I copied the code fine!