求每个数的最大质数用埃氏筛法,时间复杂度 O(nlognlogn)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
void get_primes(int n) { for (int i = 2; i <= n; i ++) if (!st[i]) { maxp[i] = i; for (int j = i; j <= n; j += i) { st[j] = true; maxp[j] = i; } } }View Code
只求质数用线性筛法
标签:Code,筛法,nlognlogn,int,质数,数学知识 From: https://www.cnblogs.com/Leocsse/p/16929574.html