简单的枚举即可。

#include <bits/stdc++.h>

using namespace std;

bool isPrime(int n)
{
    if(n == 1) return false;
    for(int i = 2; i <= sqrt(n); i ++)
    {
        if(n%i == 0) return false;
    }
    return true;
}
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        if(isPrime(n)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}