<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD</id>
	<title>质数判断 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD&amp;action=history"/>
	<updated>2026-05-17T02:30:46Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD&amp;diff=143&amp;oldid=prev</id>
		<title>33DAI：​/* 线性筛/欧拉筛 */</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD&amp;diff=143&amp;oldid=prev"/>
		<updated>2026-02-26T03:04:48Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;线性筛/欧拉筛&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年2月26日 (四) 03:04的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l60&quot;&gt;第60行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第60行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             // i*pri[j]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             // i*pri[j]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             if (i * pri[j] &amp;gt; n)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             if (&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;1LL * &lt;/ins&gt;i * pri[j] &amp;gt; n)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;                 break;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;                 break;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             p[i * pri[j]] = false;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             p[i * pri[j]] = false;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD&amp;diff=127&amp;oldid=prev</id>
		<title>33DAI：​创建页面，内容为“==判断单个质数==  &lt;math&gt;O(\sqrt{x})&lt;/math&gt;  &lt;syntaxhighlight lang=&quot;cpp&quot; line&gt; bool is_prime(long long x) {     if (x &lt; 2)         return false;     for (long long i = 2; i * i &lt;= x; i++)         if (x % i == 0)             return false;     return true; } &lt;/syntaxhighlight&gt;  ==筛法==  ===埃氏筛===  &lt;math&gt;O(n\log \log n)&lt;/math&gt;  &lt;syntaxhighlight lang=&quot;cpp&quot; line&gt; const int MAXN = 10&#039;000&#039;000; bool p[MAXN + 1]; //筛出 1~n 中的每个数是否为质数…”</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=%E8%B4%A8%E6%95%B0%E5%88%A4%E6%96%AD&amp;diff=127&amp;oldid=prev"/>
		<updated>2026-02-12T08:55:11Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“==判断单个质数==  &amp;lt;math&amp;gt;O(\sqrt{x})&amp;lt;/math&amp;gt;  &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line&amp;gt; bool is_prime(long long x) {     if (x &amp;lt; 2)         return false;     for (long long i = 2; i * i &amp;lt;= x; i++)         if (x % i == 0)             return false;     return true; } &amp;lt;/syntaxhighlight&amp;gt;  ==筛法==  ===埃氏筛===  &amp;lt;math&amp;gt;O(n\log \log n)&amp;lt;/math&amp;gt;  &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line&amp;gt; const int MAXN = 10&amp;#039;000&amp;#039;000; bool p[MAXN + 1]; //筛出 1~n 中的每个数是否为质数…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==判断单个质数==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;O(\sqrt{x})&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line&amp;gt;&lt;br /&gt;
bool is_prime(long long x)&lt;br /&gt;
{&lt;br /&gt;
    if (x &amp;lt; 2)&lt;br /&gt;
        return false;&lt;br /&gt;
    for (long long i = 2; i * i &amp;lt;= x; i++)&lt;br /&gt;
        if (x % i == 0)&lt;br /&gt;
            return false;&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==筛法==&lt;br /&gt;
&lt;br /&gt;
===埃氏筛===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;O(n\log \log n)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line&amp;gt;&lt;br /&gt;
const int MAXN = 10&amp;#039;000&amp;#039;000;&lt;br /&gt;
bool p[MAXN + 1];&lt;br /&gt;
//筛出 1~n 中的每个数是否为质数&lt;br /&gt;
void get_primes(int n)&lt;br /&gt;
{&lt;br /&gt;
    //初始化&lt;br /&gt;
    p[0] = p[1] = false;&lt;br /&gt;
    for (int i = 2; i &amp;lt;= n; i++)&lt;br /&gt;
        p[i] = true;&lt;br /&gt;
    //筛&lt;br /&gt;
    for (int i = 2; i &amp;lt;= n; i++)&lt;br /&gt;
        if (p[i])&lt;br /&gt;
            for (int j = i + i; j &amp;lt;= n; j += i)&lt;br /&gt;
                p[j] = false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===线性筛/欧拉筛===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line&amp;gt;&lt;br /&gt;
const int MAXN = 10&amp;#039;000&amp;#039;000;&lt;br /&gt;
bool p[MAXN + 1];&lt;br /&gt;
vector&amp;lt;int&amp;gt; pri;&lt;br /&gt;
// 筛出 1~n 中的每个数是否为质数&lt;br /&gt;
void get_primes(int n)&lt;br /&gt;
{&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
        p[i] = true;&lt;br /&gt;
    p[0] = p[1] = false;&lt;br /&gt;
    for (int i = 2; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        if (p[i])&lt;br /&gt;
            pri.push_back(i);&lt;br /&gt;
        for (int j = 0; j &amp;lt; pri.size(); j++)&lt;br /&gt;
        {&lt;br /&gt;
            // i*pri[j]&lt;br /&gt;
            if (i * pri[j] &amp;gt; n)&lt;br /&gt;
                break;&lt;br /&gt;
            p[i * pri[j]] = false;&lt;br /&gt;
            if (i % pri[j] == 0)&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
</feed>