【Eternallyc】素数筛选法
来源:互联网 发布:微信三点定位软件 编辑:程序博客网 时间:2024/06/03 22:25
#include <cstring>#include <cstdio>#define maxn 1000005bool i[maxn];int main(){ memset(i,0,sizeof(i));//初始化数组 i[0]=i[1]=1;//0和1不是素数,赋值为1去除 for(int a = 2;a * a<maxn;a ++)//因为有b循环所以是a*a<maxn { if(!i[a])//判断是不是素数(0表示是素数) { for(int b = 2;b * a < maxn;b ++) i[a*b]=1; } } for(int a = 0;a < 100;a ++) if(!i[a]) printf("%d ",a); return 0;}
阅读全文
0 0
- 【Eternallyc】素数筛选法
- 【Eternallyc】素数6N+1法
- 【Eternallyc】大数素数判断
- 【Eternallyc】NEFU-119-组合素数
- 筛选法求素数
- 筛选法求素数
- 筛选法求素数
- Eratoshenes素数筛选法
- 素数--超强筛选法
- 素数筛选法
- 筛选法求素数
- 筛选法求素数
- 筛选法求素数
- 筛选法求素数
- 筛选法求素数
- 筛选法求素数
- 素数筛选法
- 素数筛选法2
- 人见人爱A+B oj117
- HDU1863畅通工程
- C语言--作用域、存储期、链接
- CentOS环境下全志H3 android系统编译
- Linux常用命令
- 【Eternallyc】素数筛选法
- 判断升序 oj118
- 如何实现可迭代对象和迭代器对象(二)
- HMTL5(五)
- 阶乘因式分解
- Linux利用list_head结构实现双向链表
- 在线查询树上最近公共祖先
- js实现一些简单文本的加载
- 杨辉三角 oj120