{"id":1791,"date":"2026-06-07T00:44:41","date_gmt":"2026-06-06T16:44:41","guid":{"rendered":"http:\/\/wordpress.fangt.online\/?p=1791"},"modified":"2026-06-07T00:44:41","modified_gmt":"2026-06-06T16:44:41","slug":"%e5%9f%83%e6%b0%8f%e7%ad%9b%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"http:\/\/wordpress.fangt.online\/index.php\/2026\/06\/07\/%e5%9f%83%e6%b0%8f%e7%ad%9b%e5%85%a5%e9%97%a8\/","title":{"rendered":"\u57c3\u6c0f\u7b5b\u5165\u95e8"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u7b97\u6cd5\u7b80\u4ecb<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u57c3\u6c0f\u7b5b\u662f\u4e00\u79cd<strong>\u7b80\u5355\u4e14\u53e4\u8001<\/strong>\u7684\u6c42\u53d6\u4e0d\u8d85\u8fc7\u81ea\u7136\u6570 (n) \u7684\u6240\u6709\u7d20\u6570\uff08\u8d28\u6570\uff09\u7684\u7b97\u6cd5\u3002\u7531\u53e4\u5e0c\u814a\u6570\u5b66\u5bb6\u57c3\u62c9\u6258\u65af\u7279\u5c3c\u63d0\u51fa\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u662f<strong>\u9010\u6b65\u5254\u9664\u5408\u6570<\/strong>\uff0c\u6700\u7ec8\u7559\u4e0b\u7684\u5373\u4e3a\u7d20\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u7b97\u6cd5\u539f\u7406\u4e0e\u6b65\u9aa4<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u57fa\u672c\u601d\u60f3<\/strong>\uff1a\u4e00\u4e2a\u7d20\u6570\u7684\u500d\u6570\u4e00\u5b9a\u662f\u5408\u6570\u3002\u4ece\u6700\u5c0f\u7684\u7d20\u6570 2 \u5f00\u59cb\uff0c\u5c06\u5176\u6240\u6709\u500d\u6570\u6807\u8bb0\u4e3a\u5408\u6570\uff0c\u7136\u540e\u627e\u5230\u4e0b\u4e00\u4e2a\u672a\u88ab\u6807\u8bb0\u7684\u6570\uff08\u5373\u4e3a\u4e0b\u4e00\u4e2a\u7d20\u6570\uff09\uff0c\u91cd\u590d\u6b64\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8be6\u7ec6\u6b65\u9aa4\uff08\u6c42 2 \u5230 n \u7684\u6240\u6709\u7d20\u6570\uff09<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u521b\u5efa\u4e00\u4e2a\u957f\u5ea6\u4e3a (n+1) \u7684\u5e03\u5c14\u6570\u7ec4 <code>is_prime<\/code>\uff0c\u521d\u59cb\u5168\u90e8\u8bbe\u4e3a <code>true<\/code>\uff08\u5047\u8bbe\u6240\u6709\u6570\u90fd\u662f\u7d20\u6570\uff09\uff0c\u5e76\u5c06 <code>is_prime[0] = is_prime[1] = false<\/code>\uff080 \u548c 1 \u4e0d\u662f\u7d20\u6570\uff09\u3002<\/li>\n\n\n\n<li>\u4ece (p = 2) \u5f00\u59cb\u5faa\u73af\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c <code>is_prime[p]<\/code> \u4e3a <code>true<\/code>\uff0c\u5219\u8bf4\u660e (p) \u662f\u7d20\u6570\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5c06 (p) \u7684\u6240\u6709\u500d\u6570<math data-latex=\" (2p, 3p, 4p, \\dots) \"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><mn>2<\/mn><mi>p<\/mi><mo separator=\"true\">,<\/mo><mn>3<\/mn><mi>p<\/mi><mo separator=\"true\">,<\/mo><mn>4<\/mn><mi>p<\/mi><mo separator=\"true\">,<\/mo><mo>\u2026<\/mo><mspace width=\"0.1667em\"><\/mspace><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\"> (2p, 3p, 4p, \\dots) <\/annotation><\/semantics><\/math>\u6807\u8bb0\u4e3a <code>false<\/code>\uff08\u4ece <math data-latex=\"(p^2)\"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mi>p<\/mi><mn>2<\/mn><\/msup><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\">(p^2)<\/annotation><\/semantics><\/math> \u5f00\u59cb\u6807\u8bb0\u53ef\u4f18\u5316\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5426\u5219\uff0c\u76f4\u63a5\u8df3\u8fc7\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u4ee4 (p) \u589e\u52a0 1\uff0c\u91cd\u590d\u6b65\u9aa4 2\uff0c\u76f4\u5230 <math data-latex=\"(p^2 &gt; n)\"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mi>p<\/mi><mn>2<\/mn><\/msup><mo>&gt;<\/mo><mi>n<\/mi><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\">(p^2 &gt; n)<\/annotation><\/semantics><\/math> \u4e3a\u6b62\uff08\u56e0\u4e3a\u82e5 <math data-latex=\"(p &gt; \\sqrt{n}) \"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><mi>p<\/mi><mo>&gt;<\/mo><msqrt><mi>n<\/mi><\/msqrt><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\">(p &gt; \\sqrt{n}) <\/annotation><\/semantics><\/math>\u4e14\u672a\u88ab\u6807\u8bb0\uff0c\u5219\u5176\u500d\u6570 <math data-latex=\"(p^2 &gt; n) \"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mi>p<\/mi><mn>2<\/mn><\/msup><mo>&gt;<\/mo><mi>n<\/mi><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\">(p^2 &gt; n) <\/annotation><\/semantics><\/math>\u5df2\u7ecf\u5904\u7406\u8fc7\uff09\u3002<\/li>\n\n\n\n<li>\u904d\u5386\u6570\u7ec4\uff0c\u6240\u6709\u503c\u4e3a <code>true<\/code> \u7684\u4e0b\u6807\u5373\u4e3a\u7d20\u6570\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f18\u5316\u70b9\uff1a\u4ece<math data-latex=\" (p^2) \"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mi>p<\/mi><mn>2<\/mn><\/msup><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\"> (p^2) <\/annotation><\/semantics><\/math>\u5f00\u59cb\u6807\u8bb0<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u4e8e (p) \u7684\u500d\u6570<math data-latex=\" (k \\cdot p)\"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><mi>k<\/mi><mo>\u22c5<\/mo><mi>p<\/mi><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\"> (k \\cdot p)<\/annotation><\/semantics><\/math>\uff08\u5176\u4e2d (k &lt; p)\uff09\u4e00\u5b9a\u5df2\u7ecf\u88ab\u66f4\u5c0f\u7684\u7d20\u6570\u6807\u8bb0\u8fc7\u4e86\uff0c\u56e0\u6b64\u53ea\u9700\u4ece<math data-latex=\" (p^2) \"><semantics><mrow><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mi>p<\/mi><mn>2<\/mn><\/msup><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\"> (p^2) <\/annotation><\/semantics><\/math>\u5f00\u59cb\u6807\u8bb0\u3002\u8fd9\u5927\u5e45\u51cf\u5c11\u4e86\u91cd\u590d\u6807\u8bb0\u6b21\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u4ee3\u7801\u5b9e\u73b0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>bool is_prime&#91;10005] = {};\nfor(int i = 2; i &lt;= 10000; i++) is_prime&#91;i] = true;\n\nfor (int p = 2; p * p &lt;= n; p++) {\n    if (is_prime&#91;p]) {\n        for (int t = p * p; t &lt;= n; t += p) {\n            is_prime&#91;t] = false;\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u7b97\u6cd5\u7b80\u4ecb \u57c3\u6c0f\u7b5b\u662f\u4e00\u79cd\u7b80\u5355\u4e14\u53e4\u8001\u7684\u6c42\u53d6\u4e0d\u8d85\u8fc7\u81ea\u7136\u6570 (n) \u7684\u6240\u6709\u7d20\u6570\uff08\u8d28\u6570\uff09\u7684\u7b97\u6cd5\u3002\u7531\u53e4\u5e0c\u814a\u6570\u5b66\u5bb6\u57c3\u62c9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-1791","post","type-post","status-publish","format-standard","hentry","category-zl"],"_links":{"self":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/comments?post=1791"}],"version-history":[{"count":1,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1791\/revisions"}],"predecessor-version":[{"id":1792,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1791\/revisions\/1792"}],"wp:attachment":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/media?parent=1791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/categories?post=1791"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/tags?post=1791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}