筛法打素数表
来源:互联网 发布:中信淘宝v 编辑:程序博客网 时间:2024/05/21 06:54
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <map>#include <string>#include <cstring>#include <ctime>#define ms(a,b) memset(a,b,sizeof(a))using namespace std;typedef long long ll;const int NP = 1000005;int ispri[NP] = {}, prime[NP], pcnt = 0;void getprime(){ ispri[0] = ispri[1] = 1; for (long long i = 2; i < NP; i++) if (ispri[i] == 0) { prime[++pcnt] = i; for (long long j = i * i; j < NP; j += i) { ispri[j] = 1; } }}int main(){ ///freopen("data.txt", "r", stdin); freopen("output.txt", "w", stdout); getprime(); for (int i = 1; i <= pcnt; i++) { cout << prime[i] << endl; } return 0;}
阅读全文
0 0
- 筛法打素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数表
- 素数 表
- 素数表
- 素数表
- 素数表
- java 多线程随笔(三)
- 关于Android Activity的configChanges属性的用法,设置屏幕旋转时activity不重新创建
- 操作系统的内存管理
- ant+jmeter集成
- Python学习7-模块的定义和引用
- 筛法打素数表
- 九度1131:合唱队形
- 适配器Adapter使用
- 魔力手环 矩阵快速幂
- hdu 1079 Calendar Game
- makefile简易教程
- 5-5 堆中的路径
- 第五篇:JAVA网络编程之基于线程池的TCP服务器(含代码)
- unique 与 unique_copy 函数