ACM模板库

ACM模板库


埃氏筛

<pre><code>#include &lt;iostream&gt; using namespace std; const int maxn = 1e6+5; bool isprime[maxn]; void sieve(){ for(int i = 1; i &lt;= maxn; i++){ isprime[i] = true; } isprime[0] = isprime[1] = false; for(int i = 0; i &lt;= maxn; i++){ if(isprime[i]){ for(int j = 2*i; j &lt;= maxn; j+=i){ isprime[j] = false; } } } return; } </code></pre>

页面列表

ITEM_HTML