解题思路:判断是否可以被抹除两次,只有两次的才是质数的后代
注意事项:
参考代码:
import java.util.Scanner; public class test1565 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner=new Scanner(System.in); int count=scanner.nextInt(); int l=0; int[] x=new int[count]; for (int i = 0; i < x.length; i++) { x[i]=scanner.nextInt(); } for (int i = 0; i < x.length; i++) { int j=2; l=0; while (x[i]!=1) { if (x[i]%j==0) { l++; x[i]/=j; } else { j++; } } if (l==2) { System.out.println("Yes"); } else { System.out.println("No"); } } } }
0.0分
0 人评分
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:541 |
字符逆序 (C语言代码)浏览:615 |
母牛的故事 (C语言代码)浏览:550 |
K-进制数 (C语言描述,蓝桥杯)浏览:925 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:670 |
1014题解浏览:485 |
A+B for Input-Output Practice (III) (C语言代码)浏览:569 |
A+B for Input-Output Practice (V) (C语言代码)浏览:466 |
C语言程序设计教程(第三版)课后习题12.1 (C语言代码)浏览:646 |
数列问题 (C语言代码)浏览:1022 |