半素数

 哥德巴赫猜想(任何大于六的偶数都可以写成两个奇质数的和)

题目定义了一种叫半素数的数:只要一个数能被分解成两个素数,那么这个数就是半素数。
Prime Number Definition
An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself. For instance, 2, 11, 67, 89 are prime numbers but 8, 20, 27 are not.

Semi-Prime Number Definition
An integer greater than one is called a semi-prime number if it can be decompounded to TWO prime numbers. For example, 6 is a semi-prime number but 12 is not.

Your task is just to determinate whether a given number is a semi-prime number.

Input

There are several test cases in the input. Each case contains a single integer N (2 <= N <= 1,000,000)

Output

One line with a single integer for each case. If the number is a semi-prime number, then output "Yes", otherwise "No".

Sample Input

3
4
6
12

Sample Output
No
Yes
Yes
No

bool isPrime(long test)
{
	for (int i=0;i<=sqrt((double long)test);i++)
	{
		if(test%i==0)
			return false;
	}
	return true;
}
bool isSemiPrime(long test)
{
	for (int i=2;i<=sqrt((double long)test);i++)
	{
		if (test%i==0)
		{
			int temp=test/i;
			return isPrime(test/i)&&isPrime(temp);
		}
	}
	return false;
}

你可能感兴趣的:(常规算法探究与数据结构)