朴素筛
一、朴素筛是什么?
筛除一个序列中非的质数的数
二、应用
1.原题
2.题解实现
代码如下(示例):
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e6 + 10;
int primes[N], cnt;
bool st[N];
void get_prime(int n)
{
for(int i = 2; i <= n; i++)
{
if(!st[i])
{
primes[cnt++] = n;
for(int j = i + i;j <= n; j += i) st[j] = true;
}
}
}
该处使用的url网络请求的数据。
总结
质数——朴素筛