首页 > 其他 > 详细

【素数】Eratosthenes筛选

时间:2018-05-22 11:58:25      阅读:153      评论:0      收藏:0      [点我收藏+]

 

 

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main()
{
    /*素数筛选*/
    /*Eratosthenes筛选*/
    /*确定某一个数是素数之后,删除这个数的所有的倍数*/
    int n;
    cin >> n;
    memset(vis, 0, sizeof(vis));
    for(int i = 2; i <= sqrt(n); i++)
        if(!vis[i])
            for(int j = i * i; j <= n; j += i)
                vis[j] = 1;


}

 

【素数】Eratosthenes筛选

原文:https://www.cnblogs.com/Kohinur/p/9070855.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!