The question defines a number called a half prime number: As long as a number can be divided into two prime numbers, this number is a half prime number.
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 decompoundedTwoPrime 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
The solution is very simple. The solution is as follows:
# Include <iostream> # include <cmath> using namespace STD; bool isprime (long test) {int I; for (I = 2; I <= SQRT (Long Double) test); I ++) {If (test % I = 0) return false;} return true;} bool issemiprime (long test) {int I; for (I = 2; I <= SQRT (Long Double) Test); I ++) {If (test % I = 0) {int temp = test/I; return isprime (I) & isprime (temp) ;}} return false ;}int main () {long n; while (CIN >>n & n! = 0) {If (issemiprime (N) cout <"yes" <Endl; elsecout <"no" <Endl ;}}