- paste
判断质数
- 2022-9-21 13:46:05 @
#include<iostream>
#include<math.h>
using namespace std;
bool f(int n){
if(n==0||n==1)return false;
for(int i=2;i<=sqrt(n);i++){
if(n%i==0)return false;
}
return true;
}
int main(){
int t,n;
cin>>t;
while(t--){
cin>>n;
if(f(n))cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
0 comments
No comments so far...