基本判断思路
在一般领域,对正整数n,如果用2到 sqrt(n) 之间的所有整数去除,均无法整除,则n为质数。
质数大于等于2 ,不能被它本身和1以外的数整除
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int N;
long long x;
cin>>N;
int i=1;
while(i<=N){
cin>>x;
bool check = true;
for(int j=2;j<=(int)sqrt(x);j++){
if(x % j == 0){
check = false;
break;
}
}
if(x==1){
check = false;
}
if(check){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
i++;
}
return 0;
}