import java.io.*; /** * 筛法求素数 */ public class Main { public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); public static StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public static PrintWriter cout = new PrintWriter(new OutputStreamWriter(System.out)); static boolean[] primerNumber(int n){ boolean[] f = new boolean[n + 1]; f[0] = false; f[1] = false; for(int i = 2; i < n; i++){ f[i] = true; } for(int i = 2; i <= n; i++){ if(f[i] == true){ for(int j = 2; j * i <= n; j++){ f[i * j] = false; } } } return f; } public static void main(String[] args) throws Exception { cin.nextToken(); int n = (int) cin.nval; boolean[] f = primerNumber(n + 1); if (f[n] == true) { cout.print("prime"); } else { cout.print("not prime"); } cout.flush(); } }
0.0分
0 人评分
C语言考试练习题_排列 (C语言代码)浏览:767 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:1432 |
WU-整数平均值 (C++代码)浏览:1307 |
WU-拆分位数 (C++代码)浏览:819 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:616 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:580 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:624 |
模拟计算器 (C++代码)浏览:885 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:567 |
企业奖金发放 (C语言代码)浏览:2462 |