p113.cpp
======================
#include <bits/stdc++.h>
#define endl '\n'

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

using namespace std;
template<class T, class T2>
inline void chkmax(T& x, const T2& y) {
    if(x < y) {
        x = y;
    }
}
template<class T, class T2>
inline void chkmin(T& x, const T2& y) {
    if(x > y) {
        x = y;
    }
}
const int MAXN = (1 << 10);

int n;
int a[MAXN];

void read() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

void solve() {
    for(int i = 0; i < n; i++) {
        int c = 0;
        for(int d = 2; d * 1ll * d <= a[i]; d++) {
            while(a[i] % d == 0) {
                c++;
                a[i] /= d;
            }
        }

        if(a[i] != 1) {
            c++;
        }

        if(c == 2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    read();
    solve();
    return 0;
}

=================
statement.txt
======================
113. Nearly prime numbers

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


Nearly prime number is an integer positive number for which it is possible to find such primes P1 and P2 that given number is equal to P1*P2. There is given a sequence on N integer positive numbers, you are to write a program that prints “Yes” if given number is nearly prime and “No” otherwise.


Input

Input file consists of N+1 numbers. First is positive integer N (1£N£10). Next N numbers followed by N. Each number is not greater than 109. All numbers separated by whitespace(s).


Output

Write a line in output file for each number of given sequence. Write “Yes” in it if given number is nearly prime and “No” in other case.


Sample Input

1
6
Sample Output

Yes
Author	: Michael R. Mirzayanov
Resource	: PhTL #1 Training Contests
Date	: Fall 2001

=================
