Prime算法
来源:互联网 发布:ubuntu怎么扩展内存 编辑:程序博客网 时间:2024/05/17 22:59
#include <iostream>#include <cmath>using namespace std;void prime(bool a[], const int n);int main(){int n;bool a[1000000];cin >> n;prime(a,n);for(int i=0;i<n;i++)if(a[i] == true)cout << i << " ";cout << endl;return 0;}void prime(bool a[], const int n){//Àÿ ˝…∏—°∑®int i, j;//∆Ê ˝±ÍŒ™true£¨≈º ˝±ÍŒ™falsea[0] = false;a[1] = false;a[2] = true;for( i=3; i<n;i+=2){a[i] = true;a[i+1] = false;}//…∏—°for( i=3; i<=sqrt(n); i+=2 ) {if(a[i] == true) for( j=i+i; j<=n; j+=i )a[j] = false;}}
0 0
- Prime算法
- Prime算法
- Prime算法
- Prime算法
- prime算法
- Prime算法
- prime算法
- Prime算法
- Prime算法
- prime算法
- Prime算法
- Prime算法
- hdu 1102(prime 算法)
- 普利姆(Prime)算法
- prime算法 poj1789
- 最小树Prime算法
- 【普利姆(Prime)算法】
- prime算法--布线问题
- Fatal error: Call to** function read() on a non-object inC:*\*\select_templets.php on line *的解决方法
- Java版代码管理器
- Java 安全模型介绍
- 系统集成部和行业应用部的职责
- 使用cl编译的步骤
- Prime算法
- What technical details should a programmer of a web application consider before making the site publ
- 51nod 1090 3个数和为0 & 51nod 1267 4个数和为0(标记二分)
- 【BZOJ】【P3275】【Number】【题解】【最小割】
- Python笔记(20141130)
- 分支-07. 比较大小(10)
- HDU 5125 magic balls
- 【UNIX】什么是线程的同步和互斥
- 7个示例科普CPU Cache