Problem:
Problem A:Goldbach's Conjecture

Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2.

This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair of prime numbers, if any, for a given even number. The problem here is to write a program that reports the number of all the pairs of prime numbers satisfying the condition in the conjecture for a given even number.

A sequence of even numbers is given as input. Corresponding to each number, the program should output the number of pairs mentioned above. Notice that we are intereseted in the number of essentially different pairs and therefore you should not count (p1, p2) and (p2, p1) separately as two different pairs.

Input

An integer is given in each input line. You may assume that each integer is even, and is greater than or equal to 4 and less than 215. The end of the input is indicated by a number 0.

Output

Each output line should contain an integer number. No other characters should appear in the output.

Sample Input

6
10
12
0

Output for the Sample Input

1
2
1

Solution in C (judge verdict: Time Limit Exceeded)

#include <stdio.h>
#include <math.h>


#define	VD	void
#define	U1	unsigned char
#define	U4	unsigned int

#define	APL_FALSE	(0)
#define	APL_TRUE	(1)

#define MAX_INPUT_N				(32768)		/* 2^15??????????????????10???????????§??????????????¨?´???°?????????????¶????????????????*/
#define NUM_PRIME_NUMBER_ARR	(9592)		/* 10?????\???????´???°?????°??????????´???§????????§??????????¢???? */
#define PRIME_NUM_5				(5)			/* ?´???°??¢?´¢????§??????° */

static VD vd_s_createPrimeNumArr(U4** u4_ap_rtnArr);
static U4 u4_s_countPairs(U4 u4_a_inputN, U4* u4_ap_PrimeNumArr);

VD main()
{
	U4 u4_tp_PrimeNumArr[NUM_PRIME_NUMBER_ARR];
	U4 u4_t_inputN;
	U4 u4_t_numPairs;
	u4_t_inputN = (U4)0;
	u4_t_numPairs = (U4)0;

	/* ??\????????¨????¨????????????????????????§??????????´???°????????????????????£????????? */
	/* TODO:?´???°??????????????????????????????????????????????????§?????? */
	vd_s_createPrimeNumArr(&u4_tp_PrimeNumArr[0]);
	
	scanf("%d", &u4_t_inputN);

	u4_t_numPairs = u4_s_countPairs(u4_t_inputN, u4_tp_PrimeNumArr);

	printf("%d\n", u4_t_numPairs);

	while (1);
}

VD vd_s_createPrimeNumArr(U4 ** u4_ap_rtnArr)
{
	U4 u4_t_i;
	U4 u4_t_j;
	U4 u4_t_primeIndex;
	U4 u4_t_searchCap;
	U1 u1_t_isPrime;
	u4_t_i = (U4)0;
	u4_t_j = (U4)0;
	u4_t_primeIndex = (U4)0;

	u1_t_isPrime = (U1)APL_FALSE;

	/* 2, 3????´???° */
	u4_ap_rtnArr[0] = (U4)2;
	u4_ap_rtnArr[1] = (U4)3;
	u4_t_primeIndex = (U4)2;

	/* 3????¬?????\???°????????¢?´¢????§? */
	/* ??¶??°????´???°??§??????????????¢?´¢?????? */
	for (u4_t_i = (U4)5; u4_t_i <= (U4)MAX_INPUT_N; u4_t_i += (U4)2)
	{
		u1_t_isPrime = (U1)APL_TRUE;
		u4_t_searchCap = (U4)sqrt(u4_t_i) + (U4)1;	/* ?´???°??§????????????????????\????????°????´???°??¨????????????????????¢?´¢??????????????§??§OK */

		/* ????????°??§???????????????????´???°??§????????? */
		u4_t_j = (U4)3;		/* ??\????????????????\???°???2??§??????????????????????¢?????????????????????§3????????????*/
		while ((u4_t_j <= u4_t_searchCap) &&
			   (u1_t_isPrime != (U1)APL_FALSE))
		{
			/* ????????°??§???????????????????´???°??§????????? */
			if ((u4_t_i % u4_t_j) == 0)
			{
				u1_t_isPrime = (U4)APL_FALSE;
			}
			u4_t_j++;
		}

		/* ?´???°?????? */
		if (u1_t_isPrime == (U1)APL_TRUE)
		{
			u4_ap_rtnArr[u4_t_primeIndex] = u4_t_i;
			u4_t_primeIndex++;
		}

	}
	return;
}

U4 u4_s_countPairs(U4 u4_a_inputN, U4 * u4_ap_PrimeNumArr)
{
	U4 u4_t_prime1;
	U4 u4_t_prime2;
	U4 u4_t_i;
	U4 u4_t_primeIndex;
	U4 u4_t_cntPair;
	U4 u4_t_maxSearchNum;
	
	/* ?????????CS??????((????????????????????¢) */
	u4_t_prime1 = (U4)0;
	u4_t_prime2 = (U4)0;
	u4_t_i = (U4)0;
	u4_t_cntPair = (U4)0;
	u4_t_primeIndex = (U4)0;
	u4_t_maxSearchNum = (U4)0;

	/* ?????????????´???°p?????????????????\???N-?´???°p????´???°??§??????????¢???? */
	u4_t_maxSearchNum = (U4)ceil((double)u4_a_inputN / 2.0);		/* ???????????????????????????????????????????????????????????????????????\??????????????°?????????????????§??¢?´¢ */
	for (u4_t_i = (U4)0; u4_ap_PrimeNumArr[u4_t_i] <= u4_t_maxSearchNum; u4_t_i++)
	{
		/* ?´???°???????????????N-p????????????????????¢?´¢ */
		u4_t_prime2 = u4_a_inputN - u4_ap_PrimeNumArr[u4_t_i];
		u4_t_primeIndex = (U4)0;
		while((u4_t_primeIndex < (U4)NUM_PRIME_NUMBER_ARR) &&
			  (u4_ap_PrimeNumArr[u4_t_primeIndex] <= u4_a_inputN)) 
		{
			/* N-p????´???° */
			if (u4_ap_PrimeNumArr[u4_t_primeIndex] == u4_t_prime2)
			{
				/*???????????°??¨*/
				printf("%d, %d\n", u4_ap_PrimeNumArr[u4_t_i], u4_t_prime2);
				u4_t_cntPair++;
			}
			u4_t_primeIndex++;
		}
	}

	return(u4_t_cntPair);
}