用sqrt(m)只能通过80%
#include <iostream>
#include <cmath>using namespace std;
int main(){
int m,n,i,flag;
cin>>n;
while(n--){
cin>>m;
if(m==1)
{
cout<<"No"<<endl;
}
else {
if(m==2||m==3){
cout<<"Yes"<<endl;
}
else{
flag=0;
for(i=2;i<m;i++){//
if(m%i==0){
flag++;
break;
}
}
if(flag==0){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
}
}
}
全部评论
(1) 回帖