AcWing 866. 试除法判定质数JAVA
原题链接
简单
作者:
ARM
,
2020-08-27 21:52:30
,
所有人可见
,
阅读 471
java 代码
import java.io.*;
import java.lang.*;
class Main{
public static void main(String[] args) throws Exception{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.valueOf(buf.readLine());
while(n -- != 0){
int x = Integer.valueOf(buf.readLine());
if(x == 1){
System.out.println("No");
continue;
}
boolean flag = false;
for(int i = 2; i <= x / i; ++i){
if(x % i == 0){
flag = true;
break;
}
}
if(flag){
System.out.println("No");
}else{
System.out.println("Yes");
}
}
}
}