{"id":63331,"date":"2026-01-21T20:49:25","date_gmt":"2026-01-21T12:49:25","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/63331.html"},"modified":"2026-01-21T20:49:25","modified_gmt":"2026-01-21T12:49:25","slug":"%e5%93%a5%e5%be%b7%e5%b7%b4%e8%b5%ab%e7%8c%9c%e6%83%b3%ef%bc%88%e6%b4%9b%e8%b0%b7p1304%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/63331.html","title":{"rendered":"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09"},"content":{"rendered":"<h3>\u9898\u76ee\u63cf\u8ff0<\/h3>\n<p>\u8f93\u5165\u4e00\u4e2a\u5076\u6570\u00a0N&#xff0c;\u9a8c\u8bc1\u00a04\u223cN\u00a0\u6240\u6709\u5076\u6570\u662f\u5426\u7b26\u5408\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3&#xff1a;\u4efb\u4e00\u5927\u4e8e\u00a02\u00a0\u7684\u5076\u6570\u90fd\u53ef\u5199\u6210\u4e24\u4e2a\u8d28\u6570\u4e4b\u548c\u3002\u5982\u679c\u4e00\u4e2a\u6570\u4e0d\u6b62\u4e00\u79cd\u5206\u6cd5&#xff0c;\u5219\u8f93\u51fa\u7b2c\u4e00\u4e2a\u52a0\u6570\u76f8\u6bd4\u5176\u4ed6\u5206\u6cd5\u6700\u5c0f\u7684\u65b9\u6848\u3002\u4f8b\u5982\u00a010&#xff0c;10&#061;3&#043;7&#061;5&#043;5&#xff0c;\u5219\u00a010&#061;5&#043;5\u00a0\u662f\u9519\u8bef\u7b54\u6848\u3002<\/p>\n<h3>\u8f93\u5165\u683c\u5f0f<\/h3>\n<p>\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u6b63\u5076\u6570\u00a0N<\/p>\n<h3>\u8f93\u51fa\u683c\u5f0f<\/h3>\n<p>\u8f93\u51fa\u00a02N\u22122\u200b\u00a0\u884c\u3002\u5bf9\u4e8e\u7b2c\u00a0i\u00a0\u884c&#xff1a;<\/p>\n<p>\u9996\u5148\u5148\u8f93\u51fa\u6b63\u5076\u6570\u00a02i&#043;2&#xff0c;\u7136\u540e\u8f93\u51fa\u7b49\u53f7&#xff0c;\u518d\u8f93\u51fa\u52a0\u548c\u4e3a\u00a02i&#043;2\u00a0\u4e14\u7b2c\u4e00\u4e2a\u52a0\u6570\u6700\u5c0f\u7684\u4e24\u4e2a\u8d28\u6570&#xff0c;\u4ee5\u52a0\u53f7\u9694\u5f00\u3002<\/p>\n<h3>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b<\/h3>\n<p>\u8f93\u5165 #1\u590d\u5236\u8fd0\u884c<\/p>\n<p>10<\/p>\n<p>\u8f93\u51fa #1\u590d\u5236\u8fd0\u884c<\/p>\n<p>4&#061;2&#043;2<br \/>\n6&#061;3&#043;3<br \/>\n8&#061;3&#043;5<br \/>\n10&#061;3&#043;7<\/p>\n<h3>\u8bf4\u660e\/\u63d0\u793a<\/h3>\n<p>\u6570\u636e\u4fdd\u8bc1&#xff0c;4\u2264N\u226410000\u3002<\/p>\n<\/p>\n<p>\u5728\u7b97\u6cd5\u7ade\u8d5b\u4e2d&#xff0c;\u7d20\u6570\u7b5b\u6cd5\u662f\u6570\u8bba\u9898\u76ee\u7684\u57fa\u77f3\u3002\u672c\u6587\u5c06\u4ee5\u6d1b\u8c37\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\u9a8c\u8bc1\u4e3a\u4f8b&#xff0c;\u6df1\u5165\u62c6\u89e3\u4e24\u79cd\u6838\u5fc3\u7b5b\u6cd5&#xff1a;\u57c3\u6c0f\u7b5b\u4e0e\u6b27\u62c9\u7b5b&#xff0c;\u5e76\u7528\u8868\u683c\u6f14\u793a\u5b83\u4eec\u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002<\/p>\n<h3>0. \u9898\u76ee\u6838\u5fc3<\/h3>\n<ul>\n<li>\n<p>\u76ee\u6807&#xff1a;\u9a8c\u8bc14&#8211;N\u7684\u5076\u6570\u662f\u5426\u7b26\u5408\u201c\u4efb\u610f\u5927\u4e8e2\u7684\u5076\u6570&#061;\u4e24\u4e2a\u8d28\u6570\u4e4b\u548c\u201d\u3002<\/p>\n<\/li>\n<li>\n<p>\u96be\u70b9&#xff1a;N&#061;10000\u867d\u7136\u4e0d\u5927&#xff0c;\u4f46\u5728\u9a8c\u8bc1\u65f6\u9700\u8981\u9891\u7e41\u5224\u65ad\u4e00\u4e2a\u6570\u662f\u5426\u4e3a\u7d20\u6570\u3002\u5982\u679c\u6bcf\u6b21\u90fd\u5faa\u73af\u5224\u65ad&#xff0c;\u6548\u7387\u592a\u4f4e\u3002\u6211\u4eec\u9700\u8981\u9884\u5904\u7406\u51fa\u4e00\u4e2a\u7d20\u6570\u8868\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>1. \u65b9\u6cd5\u4e00&#xff1a;\u57c3\u6c0f\u7b5b\u6cd5 (Sieve of Eratosthenes)<\/h3>\n<p>\u8fd9\u662f\u6700\u76f4\u89c2\u7684\u201c\u5212\u5708\u6cd5\u201d\u3002<\/p>\n<h4>\u6838\u5fc3\u903b\u8f91&#xff08;\u6587\u672c\u6f14\u793a&#xff09;<\/h4>\n<p>\u60f3\u8c61\u4e00\u4e2a\u4ece2\u5230N\u7684\u6570\u5b57\u5217\u8868\u3002<\/p>\n<li>\n<p>\u7b2c\u4e00\u8f6e&#xff1a;\u627e\u5230\u7b2c\u4e00\u4e2a\u6ca1\u88ab\u5212\u6389\u7684\u65702&#xff08;\u5b83\u662f\u7d20\u6570&#xff09;\u3002\u7136\u540e\u628a\u6240\u67092\u7684\u500d\u6570&#xff08;4, 6, 8, 10&#8230;&#xff09;\u5168\u90e8\u5212\u6389&#xff08;\u6807\u8bb0\u4e3a\u5408\u6570&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e8c\u8f6e&#xff1a;\u4e0b\u4e00\u4e2a\u6ca1\u88ab\u5212\u6389\u7684\u6570\u662f3&#xff08;\u5b83\u662f\u7d20\u6570&#xff09;\u3002\u628a\u6240\u67093\u7684\u500d\u6570&#xff08;6, 9, 12, 15&#8230;&#xff09;\u5168\u90e8\u5212\u6389\u3002<\/p>\n<ul>\n<li>\n<p>\u6ce8\u610f6\u5728\u7b2c\u4e00\u8f6e\u5df2\u7ecf\u88ab2\u5212\u8fc7\u4e86&#xff0c;\u8fd9\u91cc\u53c8\u88ab3\u5212\u4e86\u4e00\u6b21\u3002\u8fd9\u5c31\u662f\u6548\u7387\u635f\u8017\u70b9\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u7b2c\u4e09\u8f6e&#xff1a;4\u5df2\u7ecf\u88ab\u5212\u6389\u4e86&#xff0c;\u8df3\u8fc7\u3002\u4e0b\u4e00\u4e2a\u662f5&#8230;<\/p>\n<\/li>\n<li>\n<p>\u7ed3\u675f&#xff1a;\u4e00\u76f4\u64cd\u4f5c\u5230 <img decoding=\"async\" alt=\"\\\\sqrt{}\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121124924-6970cb5470762.png\" \/>N\u00a0\u4e3a\u6b62\u3002<\/p>\n<\/li>\n<h4>\u4ee3\u7801\u5b9e\u73b0<\/h4>\n<p>void esieve(){<br \/>\n    \/\/0\u548c1\u4e0d\u662f\u7d20\u6570&#xff0c;\u624b\u52a8\u521d\u59cb\u5316<br \/>\n    es[0]&#061;1;<br \/>\n    es[1]&#061;1;<br \/>\n    for(int i&#061;2;i&lt;&#061;n\/i;i&#043;&#043;){<br \/>\n        \/\/\u5982\u679ces[i]\u662f0&#xff0c;\u4ee3\u8868i\u662f\u7d20\u6570<br \/>\n        if(es[i]&#061;&#061;0){<br \/>\n        \/\/\u65e2\u7136i\u662f\u7d20\u6570&#xff0c;\u90a3\u4e48i\u7684\u500d\u6570&#xff08;2\u500d\u30013\u500d&#8230;&#xff09;\u80af\u5b9a\u5c31\u662f\u5408\u6570\u3002<br \/>\n        \/\/j\u4ee3\u8868\u500d\u6570\u3002\u53ea\u8981i*j\u8fd8\u5728\u8303\u56f4n\u4ee5\u5185&#xff0c;\u6211\u4eec\u5c31\u4e00\u4e2a\u4e2a\u6807\u8bb0\u3002<br \/>\n            for(int j&#061;2;j&lt;&#061;n\/i;j&#043;&#043;)<br \/>\n                es[i*j]&#061;1;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3>2. \u65b9\u6cd5\u4e8c&#xff1a;\u6b27\u62c9\u7b5b (Euler Sieve \/ \u7ebf\u6027\u7b5b)<\/h3>\n<p>\u6b27\u62c9\u7b5b\u662f\u4e3a\u4e86\u89e3\u51b3\u57c3\u6c0f\u7b5b\u201c\u91cd\u590d\u6807\u8bb0\u201d\u7684\u95ee\u9898&#xff08;\u6bd4\u59826\u65e2\u88ab2\u7b5b&#xff0c;\u53c8\u88ab3\u7b5b&#xff09;\u3002<\/p>\n<p>\u6838\u5fc3\u6cd5\u5219&#xff1a;\u6bcf\u4e2a\u5408\u6570&#xff0c;\u53ea\u88ab\u5b83\u201c\u6700\u5c0f\u201d\u7684\u8d28\u56e0\u5b50\u7b5b\u6389\u3002<\/p>\n<h4>\u7b97\u6cd5\u6b65\u9aa4\u62c6\u89e3<\/h4>\n<p>\u6211\u4eec\u9700\u8981\u4e24\u4e2a\u6570\u7ec4&#xff1a;<\/p>\n<ul>\n<li>\n<p>es[]: \u6807\u8bb0\u662f\u5426\u4e3a\u5408\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>prime[]: \u5b58\u76ee\u524d\u627e\u5230\u7684\u7d20\u6570\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u6570 i (\u4ece2\u5230N)&#xff1a;<\/p>\n<li>\n<p>\u5982\u679c i \u662f\u7d20\u6570&#xff0c;\u52a0\u5165prime\u8868\u3002<\/p>\n<\/li>\n<li>\n<p>&#xff08;\u5173\u952e\u6b65\u9aa4&#xff09; \u904d\u5386\u5f53\u524d\u5df2\u6709\u7684\u7d20\u6570prime[j]&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6807\u8bb0i*prime[j] \u4e3a\u5408\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u505c\u6b62\u6761\u4ef6&#xff1a;\u5982\u679ci%prime[j]&#061;&#061;0&#xff0c;\u7acb\u523bbreak\u505c\u6b62\u5faa\u73af\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h4>\u4e3a\u4ec0\u4e48\u9700\u8981 break&#xff1f;&#xff08;\u6a21\u62df\u6267\u884c\u8868&#xff09;<\/h4>\n<p>\u8fd9\u662f\u6b27\u62c9\u7b5b\u6700\u96be\u61c2\u7684\u5730\u65b9\u3002\u8ba9\u6211\u4eec\u901a\u8fc7\u8868\u683c\u6765\u770b\u770b&#xff0c;\u5982\u679c\u4e0d\u52a0break\u4f1a\u53d1\u751f\u4ec0\u4e48&#xff0c;\u52a0\u4e86\u53c8\u4f1a\u600e\u6837\u3002<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u8981\u7b5b\u7684\u8303\u56f4\u7a0d\u5927\u4e00\u70b9&#xff0c;\u5f53\u524d\u904d\u5386\u5230 i&#061;4\u3002<\/p>\n<p>\u6b64\u65f6\u7d20\u6570\u8868 prime \u91cc\u6709&#xff1a;[2, 3]\u3002<\/p>\n<table>\n<tr>\n<td>\u6b65\u9aa4<\/td>\n<td>\u5f53\u524d\u6570 i<\/td>\n<td>\u904d\u5386\u7d20\u6570 prime[j]<\/td>\n<td>\u7b5b\u6389\u7684\u6570 (i * prime[j])<\/td>\n<td>\u5173\u952e\u5224\u65ad (i%prime[j]&#061;&#061;0?)<\/td>\n<td>\u7ed3\u679c<\/td>\n<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>4<\/td>\n<td>2<\/td>\n<td>\u7b5b\u6389 8 (4*2)<\/td>\n<td>4%2&#061;&#061;0 (\u6210\u7acb)<\/td>\n<td>Break! \u9000\u51fa\u5faa\u73af<\/td>\n<\/tr>\n<tr>\n<td>(\u5047\u8bbe\u65e0Break)<\/td>\n<td>4<\/td>\n<td>3<\/td>\n<td>\u7b5b\u6389 12 (4*3)<\/td>\n<td>&#8211;<\/td>\n<td>(\u8fd9\u6b65\u88ab\u4f18\u5316\u6389\u4e86)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6df1\u5ea6\u89e3\u6790&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6211\u4eec\u7b5b\u6389\u4e86 8\u30028 \u7684\u6700\u5c0f\u8d28\u56e0\u5b50\u662f 2\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u6211\u4eec\u7ee7\u7eed&#xff0c;\u4f1a\u7b5b\u6389 12 (4*3)\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f46\u662f&#xff0c;12\u7684\u6700\u5c0f\u8d28\u56e0\u5b50\u5176\u5b9e\u662f 2 (12&#061;2*6)\u3002<\/p>\n<\/li>\n<li>\n<p>\u6839\u636e\u6b27\u62c9\u7b5b\u7684\u6cd5\u5219\u201c\u53ea\u7531\u6700\u5c0f\u8d28\u56e0\u5b50\u7b5b\u6389\u201d&#xff0c;12 \u5e94\u8be5\u5728\u672a\u6765\u5f53 i&#061;6 \u7684\u65f6\u5019&#xff0c;\u88ab 2 (6*2) \u7b5b\u6389\u3002<\/p>\n<\/li>\n<li>\n<p>\u6240\u4ee5&#xff0c;\u5728 i&#061;4 \u65f6&#xff0c;\u4e00\u65e6\u53d1\u73b04%2&#061;&#061;0&#xff0c;\u8bf4\u660e4\u5305\u542b\u4e86\u56e0\u5b502\u3002\u90a3\u4e484\u4e58\u4ee5\u4efb\u4f55\u66f4\u5927\u7684\u7d20\u6570&#xff08;\u6bd4\u5982 3, 5&#8230;&#xff09;&#xff0c;\u7ed3\u679c\u80af\u5b9a\u4e5f\u5305\u542b\u56e0\u5b50 2\u3002\u4e3a\u4e86\u4e0d\u62a2\u201c2\u201d\u7684\u5de5\u4f5c&#xff0c;\u6211\u4eec\u5fc5\u987b\u5728\u8fd9\u91cc\u505c\u6b62\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>\u4ee3\u7801\u5b9e\u73b0<\/h4>\n<p>void Prime(){<br \/>\n    \/\/\u5916\u5c42\u662f\u500d\u6570<br \/>\n    for(int i&#061;2;i&lt;&#061;n;i&#043;&#043;){<br \/>\n        if(es[i]&#061;&#061;0){\/\/\u5982\u679ces[i]\u662f0&#xff0c;\u4ee3\u8868i\u662f\u7d20\u6570<br \/>\n            k&#043;&#043;;<br \/>\n            prime[k]&#061;i;\/\/\u8bb0\u5f55\u7d20\u6570<br \/>\n        }<br \/>\n        \/\/\u5185\u5c42\u603b\u5171\u6709k\u4e2a\u7d20\u6570&#043;\u9632\u6b62\u8d8a\u754c<br \/>\n        for(int j&#061;1;j&lt;&#061;k &amp;&amp; i*prime[j]&lt;&#061;n;j&#043;&#043;){<br \/>\n            \/\/\u7d20\u6570\u7684\u500d\u6570\u80af\u5b9a\u6807\u8bb0\u4e3a\u5408\u6570<br \/>\n            es[i*prime[j]]&#061;1;<br \/>\n\/\/\u5982\u679ci\u80fd\u88ab prime[j]\u6574\u9664&#xff0c;\u8bf4\u660e prime[j]\u662fi\u7684\u6700\u5c0f\u8d28\u56e0\u5b50<br \/>\n\/\/ \u540e\u9762\u7684\u7d20\u6570\u66f4\u5927&#xff0c;\u4e58\u79ef\u7684\u6700\u5c0f\u8d28\u56e0\u5b50\u4f9d\u7136\u662fprime[j]&#xff0c;\u7559\u7ed9\u540e\u9762\u7b5b&#xff0c;\u8fd9\u91cc\u8df3\u51fa<br \/>\n            if(i%prime[j]&#061;&#061;0) break;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3>3. \u9898\u76ee\u89e3\u6cd5&#xff1a;\u5bfb\u627e\u6700\u5c0f\u52a0\u6570<\/h3>\n<p>\u9898\u76ee\u8981\u6c42&#xff1a;\u5bf9\u4e8e\u5076\u6570N&#xff0c;\u8f93\u51fa N&#061;A&#043;B&#xff0c;\u4e14 A \u662f\u6240\u6709\u65b9\u6848\u4e2d\u6700\u5c0f\u7684\u3002<\/p>\n<p>\u7b56\u7565&#xff1a;<\/p>\n<li>\n<p>\u5916\u5c42\u5faa\u73af\u904d\u5386\u6240\u6709\u5076\u6570i (4\u5230N)\u3002<\/p>\n<\/li>\n<li>\n<p>\u5185\u5c42\u5faa\u73af\u76f4\u63a5\u904d\u5386\u6211\u4eec\u5728\u7b5b\u6cd5\u4e2d\u751f\u6210\u7684prime\u6570\u7ec4&#xff08;\u4ece\u5c0f\u5230\u5927&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4e8e\u6bcf\u4e2a\u7d20\u6570p&#xff0c;\u5224\u65adi-p\u662f\u5426\u4e5f\u662f\u7d20\u6570&#xff08;\u67e5es\u8868&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e00\u65e6\u627e\u5230&#xff0c;\u76f4\u63a5\u8f93\u51fa\u5e76break\u3002\u56e0\u4e3aprime\u6570\u7ec4\u672c\u8eab\u5c31\u662f\u6709\u5e8f\u7684&#xff0c;\u7b2c\u4e00\u4e2a\u627e\u5230\u7684\u4e00\u5b9a\u662f A \u6700\u5c0f\u7684\u65b9\u6848\u3002<\/p>\n<\/li>\n<hr \/>\n<h3>4. \u5b8c\u6574\u4ee3\u7801\u00a0<\/h3>\n<p>\/\/ \/\/\u57c3\u6c0f\u7b5b\u6cd5<br \/>\n\/\/ #include &lt;iostream&gt;<br \/>\n\/\/ using namespace std;<br \/>\n\/\/ int es[10010];\/\/\u57c3\u6c0f\u8868 \u7d20\u6570\u4e3a0 \u975e\u7d20\u6570\u4e3a1<br \/>\n\/\/ int n;<\/p>\n<p>\/\/ void esieve(){<br \/>\n\/\/     \/\/0\u548c1\u4e0d\u662f\u7d20\u6570&#xff0c;\u624b\u52a8\u521d\u59cb\u5316<br \/>\n\/\/     es[0]&#061;1;<br \/>\n\/\/     es[1]&#061;1;<br \/>\n\/\/     for(int i&#061;2;i&lt;&#061;n\/i;i&#043;&#043;){<br \/>\n\/\/         \/\/\u5982\u679ces[i]\u662f0&#xff0c;\u4ee3\u8868i\u662f\u7d20\u6570<br \/>\n\/\/         if(es[i]&#061;&#061;0){<br \/>\n\/\/         \/\/\u65e2\u7136i\u662f\u7d20\u6570&#xff0c;\u90a3\u4e48i\u7684\u500d\u6570&#xff08;2\u500d\u30013\u500d&#8230;&#xff09;\u80af\u5b9a\u5c31\u662f\u5408\u6570\u3002<br \/>\n\/\/         \/\/j\u4ee3\u8868\u500d\u6570\u3002\u53ea\u8981i*j\u8fd8\u5728\u8303\u56f4n\u4ee5\u5185&#xff0c;\u6211\u4eec\u5c31\u4e00\u4e2a\u4e2a\u6807\u8bb0\u3002<br \/>\n\/\/             for(int j&#061;2;j&lt;&#061;n\/i;j&#043;&#043;)<br \/>\n\/\/                 es[i*j]&#061;1;<br \/>\n\/\/         }<br \/>\n\/\/     }<br \/>\n\/\/ }<br \/>\n\/\/ int main(){<br \/>\n\/\/     cin&gt;&gt;n;<br \/>\n\/\/     \/\/\u5148\u6c42\u51fan\u4ee5\u5185\u6240\u6709\u7d20\u6570<br \/>\n\/\/     esieve();<br \/>\n\/\/     \/\/\u9a8c\u8bc14\u223cN\u6240\u6709\u5076\u6570\u662f\u5426\u7b26\u5408\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3<br \/>\n\/\/     for(int i&#061;4;i&lt;&#061;n;i&#061;i&#043;2){<br \/>\n\/\/         for(int j&#061;2;j&lt;&#061;n\/2;j&#043;&#043;){<br \/>\n\/\/             if(es[j]&#061;&#061;0 &amp;&amp; es[i-j]&#061;&#061;0){<br \/>\n\/\/                 cout&lt;&lt;i&lt;&lt;&#034;&#061;&#034;&lt;&lt;j&lt;&lt;&#034;&#043;&#034;&lt;&lt;i-j&lt;&lt;endl;<br \/>\n\/\/                 break;<br \/>\n\/\/             }<br \/>\n\/\/         }<br \/>\n\/\/     }<br \/>\n\/\/     return 0;<br \/>\n\/\/ }<\/p>\n<p>\/\/\u6b27\u62c9\u7b5b<br \/>\n#include &lt;iostream&gt;<br \/>\nusing namespace std;<br \/>\nint es[10010];\/\/\u6807\u8bb0\u6570\u7ec4 (0\u8868\u793a\u672a\u88ab\u7b5b\u6389&#xff0c;\u5373\u7d20\u6570&#xff1b;1\u8868\u793a\u975e\u7d20\u6570)<br \/>\nint prime[10010];\/\/\u7d20\u6570\u8868<br \/>\nint k;\/\/\u8bb0\u5f55\u7d20\u6570\u4e2a\u6570<br \/>\nint n;<\/p>\n<p>void Prime(){<br \/>\n    \/\/\u5916\u5c42\u662f\u500d\u6570<br \/>\n    for(int i&#061;2;i&lt;&#061;n;i&#043;&#043;){<br \/>\n        if(es[i]&#061;&#061;0){\/\/\u5982\u679ces[i]\u662f0&#xff0c;\u4ee3\u8868i\u662f\u7d20\u6570<br \/>\n            k&#043;&#043;;<br \/>\n            prime[k]&#061;i;\/\/\u8bb0\u5f55\u7d20\u6570<br \/>\n        }<br \/>\n        \/\/\u5185\u5c42\u603b\u5171\u6709k\u4e2a\u7d20\u6570&#043;\u9632\u6b62\u8d8a\u754c<br \/>\n        for(int j&#061;1;j&lt;&#061;k &amp;&amp; i*prime[j]&lt;&#061;n;j&#043;&#043;){<br \/>\n            \/\/\u7d20\u6570\u7684\u500d\u6570\u80af\u5b9a\u6807\u8bb0\u4e3a\u5408\u6570<br \/>\n            es[i*prime[j]]&#061;1;<br \/>\n\/\/\u5982\u679ci\u80fd\u88ab prime[j]\u6574\u9664&#xff0c;\u8bf4\u660e prime[j]\u662fi\u7684\u6700\u5c0f\u8d28\u56e0\u5b50<br \/>\n\/\/ \u540e\u9762\u7684\u7d20\u6570\u66f4\u5927&#xff0c;\u4e58\u79ef\u7684\u6700\u5c0f\u8d28\u56e0\u5b50\u4f9d\u7136\u662fprime[j]&#xff0c;\u7559\u7ed9\u540e\u9762\u7b5b&#xff0c;\u8fd9\u91cc\u8df3\u51fa<br \/>\n            if(i%prime[j]&#061;&#061;0) break;<br \/>\n        }<br \/>\n    }<br \/>\n}<br \/>\nint main(){<br \/>\n    cin&gt;&gt;n;<br \/>\n    Prime();<br \/>\n    \/\/for(int i&#061;1;i&lt;&#061;k;i&#043;&#043;) cout&lt;&lt;prime[i]&lt;&lt;&#034; &#034;;<\/p>\n<p>    for(int i&#061;4;i&lt;&#061;n;i&#061;i&#043;2){<br \/>\n        for(int j&#061;1;j&lt;&#061;k;j&#043;&#043;){<br \/>\n            if(es[i-prime[j]]&#061;&#061;0){<br \/>\n                cout&lt;&lt;i&lt;&lt;&#034;&#061;&#034;&lt;&lt;prime[j]&lt;&lt;&#034;&#043;&#034;&lt;&lt;i-prime[j]&lt;&lt;endl;<br \/>\n                break;<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>}<\/p>\n<h3>5. \u603b\u7ed3\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\n<td>\u7279\u6027<\/td>\n<td>\u57c3\u6c0f\u7b5b (Eratosthenes)<\/td>\n<td>\u6b27\u62c9\u7b5b (Euler)<\/td>\n<\/tr>\n<tbody>\n<tr>\n<td>\u539f\u7406<\/td>\n<td>\u66b4\u529b\u5212\u6389\u6240\u6709\u500d\u6570<\/td>\n<td>\u4ec5\u901a\u8fc7\u6700\u5c0f\u8d28\u56e0\u5b50\u5212\u6389\u5408\u6570<\/td>\n<\/tr>\n<tr>\n<td>\u6548\u7387<\/td>\n<td>\u7a0d\u6162 (\u6709\u91cd\u590d\u64cd\u4f5c)<\/td>\n<td>\u6700\u5feb (\u7ebf\u6027O(N))<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7801\u96be\u5ea6<\/td>\n<td>\u7b80\u5355\u76f4\u89c2<\/td>\n<td>\u9700\u8981\u7406\u89e3break\u7684\u6570\u5b66\u542b\u4e49<\/td>\n<\/tr>\n<tr>\n<td>\u672c\u9898\u63a8\u8350<\/td>\n<td>\u5b8c\u5168\u591f\u7528<\/td>\n<td>\u6700\u4f73\u6548\u7387<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0\u8f93\u5165\u4e00\u4e2a\u5076\u6570\u00a0N&#xff0c;\u9a8c\u8bc1\u00a04\u223cN\u00a0\u6240\u6709\u5076\u6570\u662f\u5426\u7b26\u5408\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3&#xff1a;\u4efb\u4e00\u5927\u4e8e\u00a02\u00a0\u7684\u5076\u6570\u90fd\u53ef\u5199\u6210\u4e24\u4e2a\u8d28\u6570\u4e4b\u548c\u3002\u5982\u679c\u4e00\u4e2a\u6570\u4e0d\u6b62\u4e00\u79cd\u5206\u6cd5&#xff0c;\u5219\u8f93\u51fa\u7b2c\u4e00\u4e2a\u52a0\u6570\u76f8\u6bd4\u5176\u4ed6\u5206\u6cd5\u6700\u5c0f\u7684\u65b9\u6848\u3002\u4f8b\u5982\u00a010&#xff0c;103755&#xff0c;\u5219\u00a01055\u00a0\u662f\u9519\u8bef\u7b54\u6848\u3002\u8f93\u5165\u683c\u5f0f\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u6b63\u5076\u6570\u00a0N\u8f93\u51fa\u683c\u5f0f\u8f93\u51fa\u00a02N\u22122\u200b\u00a0\u884c\u3002\u5bf9\u4e8e\u7b2c\u00a0i\u00a0\u884c&#xff1a;\u9996\u5148\u5148\u8f93\u51fa\u6b63\u5076\u6570\u00a02i2&#xff0c;\u7136\u540e\u8f93\u51fa\u7b49\u53f7&#xff0c;\u518d\u8f93\u51fa\u52a0\u548c\u4e3a\u00a02i2\u00a0<\/p>\n","protected":false},"author":2,"featured_media":63330,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6701,6703,6700,6702,55,4145,427],"topic":[],"class_list":["post-63331","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-6701","tag-6703","tag-6700","tag-6702","tag-c","tag-4145","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/63331.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u9898\u76ee\u63cf\u8ff0\u8f93\u5165\u4e00\u4e2a\u5076\u6570\u00a0N&#xff0c;\u9a8c\u8bc1\u00a04\u223cN\u00a0\u6240\u6709\u5076\u6570\u662f\u5426\u7b26\u5408\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3&#xff1a;\u4efb\u4e00\u5927\u4e8e\u00a02\u00a0\u7684\u5076\u6570\u90fd\u53ef\u5199\u6210\u4e24\u4e2a\u8d28\u6570\u4e4b\u548c\u3002\u5982\u679c\u4e00\u4e2a\u6570\u4e0d\u6b62\u4e00\u79cd\u5206\u6cd5&#xff0c;\u5219\u8f93\u51fa\u7b2c\u4e00\u4e2a\u52a0\u6570\u76f8\u6bd4\u5176\u4ed6\u5206\u6cd5\u6700\u5c0f\u7684\u65b9\u6848\u3002\u4f8b\u5982\u00a010&#xff0c;103755&#xff0c;\u5219\u00a01055\u00a0\u662f\u9519\u8bef\u7b54\u6848\u3002\u8f93\u5165\u683c\u5f0f\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u6b63\u5076\u6570\u00a0N\u8f93\u51fa\u683c\u5f0f\u8f93\u51fa\u00a02N\u22122\u200b\u00a0\u884c\u3002\u5bf9\u4e8e\u7b2c\u00a0i\u00a0\u884c&#xff1a;\u9996\u5148\u5148\u8f93\u51fa\u6b63\u5076\u6570\u00a02i2&#xff0c;\u7136\u540e\u8f93\u51fa\u7b49\u53f7&#xff0c;\u518d\u8f93\u51fa\u52a0\u548c\u4e3a\u00a02i2\u00a0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/63331.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-21T12:49:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121124924-6970cb5470762.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63331.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/63331.html\",\"name\":\"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-21T12:49:25+00:00\",\"dateModified\":\"2026-01-21T12:49:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/63331.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/63331.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63331.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/63331.html","og_locale":"zh_CN","og_type":"article","og_title":"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u9898\u76ee\u63cf\u8ff0\u8f93\u5165\u4e00\u4e2a\u5076\u6570\u00a0N&#xff0c;\u9a8c\u8bc1\u00a04\u223cN\u00a0\u6240\u6709\u5076\u6570\u662f\u5426\u7b26\u5408\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3&#xff1a;\u4efb\u4e00\u5927\u4e8e\u00a02\u00a0\u7684\u5076\u6570\u90fd\u53ef\u5199\u6210\u4e24\u4e2a\u8d28\u6570\u4e4b\u548c\u3002\u5982\u679c\u4e00\u4e2a\u6570\u4e0d\u6b62\u4e00\u79cd\u5206\u6cd5&#xff0c;\u5219\u8f93\u51fa\u7b2c\u4e00\u4e2a\u52a0\u6570\u76f8\u6bd4\u5176\u4ed6\u5206\u6cd5\u6700\u5c0f\u7684\u65b9\u6848\u3002\u4f8b\u5982\u00a010&#xff0c;103755&#xff0c;\u5219\u00a01055\u00a0\u662f\u9519\u8bef\u7b54\u6848\u3002\u8f93\u5165\u683c\u5f0f\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u6b63\u5076\u6570\u00a0N\u8f93\u51fa\u683c\u5f0f\u8f93\u51fa\u00a02N\u22122\u200b\u00a0\u884c\u3002\u5bf9\u4e8e\u7b2c\u00a0i\u00a0\u884c&#xff1a;\u9996\u5148\u5148\u8f93\u51fa\u6b63\u5076\u6570\u00a02i2&#xff0c;\u7136\u540e\u8f93\u51fa\u7b49\u53f7&#xff0c;\u518d\u8f93\u51fa\u52a0\u548c\u4e3a\u00a02i2\u00a0","og_url":"https:\/\/www.wsisp.com\/helps\/63331.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-21T12:49:25+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121124924-6970cb5470762.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/63331.html","url":"https:\/\/www.wsisp.com\/helps\/63331.html","name":"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-21T12:49:25+00:00","dateModified":"2026-01-21T12:49:25+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/63331.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/63331.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/63331.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u54e5\u5fb7\u5df4\u8d6b\u731c\u60f3\uff08\u6d1b\u8c37P1304\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/63331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=63331"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/63331\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/63330"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=63331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=63331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=63331"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=63331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}