{"id":119,"date":"2026-03-16T09:55:26","date_gmt":"2026-03-16T01:55:26","guid":{"rendered":"https:\/\/blog.heroking2000.com\/?p=119"},"modified":"2026-03-16T23:02:15","modified_gmt":"2026-03-16T15:02:15","slug":"%e6%9b%b4%e5%a5%87%e6%80%aa%e7%9a%84%e7%85%a7%e7%89%87","status":"publish","type":"post","link":"https:\/\/www.heroking2000.com\/?p=119","title":{"rendered":"\u66f4\u5947\u602a\u7684\u7167\u7247"},"content":{"rendered":"\n<p>\u3010\u9898\u76ee\u63cf\u8ff0\u3011<\/p>\n\n\n\n<p>Farmer John \u6b63\u518d\u4e00\u6b21\u5c1d\u8bd5\u7ed9\u4ed6\u7684\u00a0<math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mi>N<\/mi><\/mrow><\/semantics><\/math>\u00a0\u5934\u5976\u725b\u62cd\u7167\uff08<math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mn>2<\/mn><mo>\u2264<\/mo><mi>N<\/mi><mo>\u2264<\/mo><mn>1000<\/mn><\/mrow><\/semantics><\/math>\uff09\u3002<\/p>\n\n\n\n<p>\u6bcf\u5934\u5976\u725b\u6709\u4e00\u4e2a\u8303\u56f4\u5728\u00a0<math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mn>1<\/mn><mo>\u2026<\/mo><mn>100<\/mn><\/mrow><\/semantics><\/math>\u00a0\u4e4b\u5185\u7684\u6574\u6570\u7684\u300c\u54c1\u79cd\u7f16\u53f7\u300d\u3002Farmer John \u5bf9\u4ed6\u7684\u7167\u7247\u6709\u4e00\u4e2a\u5341\u5206\u53e4\u602a\u7684\u6784\u601d\uff1a\u4ed6\u5e0c\u671b\u5c06\u6240\u6709\u7684\u5976\u725b\u5206\u4e3a\u4e0d\u76f8\u4ea4\u7684\u82e5\u5e72\u7ec4\uff08\u6362\u53e5\u8bdd\u8bf4\uff0c\u5c06\u6bcf\u5934\u5976\u725b\u5206\u5230\u6070\u597d\u4e00\u7ec4\u4e2d\uff09\u5e76\u5c06\u8fd9\u4e9b\u7ec4\u6392\u6210\u4e00\u884c\uff0c\u4f7f\u5f97\u7b2c\u4e00\u7ec4\u7684\u5976\u725b\u7684\u54c1\u79cd\u7f16\u53f7\u4e4b\u548c\u4e3a\u5076\u6570\uff0c\u7b2c\u4e8c\u7ec4\u7684\u7f16\u53f7\u4e4b\u548c\u4e3a\u5947\u6570\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u5947\u5076\u4ea4\u66ff\u3002<\/p>\n\n\n\n<p>Farmer John \u53ef\u4ee5\u5206\u6210\u7684\u6700\u5927\u7ec4\u6570\u662f\u591a\u5c11\uff1f<\/p>\n\n\n\n<p>\u3010\u8f93\u5165\u683c\u5f0f\u3011<\/p>\n\n\n\n<p>\u8f93\u5165\u7684\u7b2c\u4e00\u884c\u5305\u542b\u00a0<em>N<\/em>\u3002\u4e0b\u4e00\u884c\u5305\u542b\u00a0<em>N<\/em>\u00a0\u4e2a\u7a7a\u683c\u5206\u9694\u7684\u6574\u6570\uff0c\u4e3a\u00a0<em>N<\/em>\u00a0\u5934\u5976\u725b\u7684\u54c1\u79cd\u7f16\u53f7\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u51fa\u683c\u5f0f\u3011<\/p>\n\n\n\n<p>\u8f93\u51fa Farmer John \u7684\u7167\u7247\u4e2d\u7684\u6700\u5927\u7ec4\u6570\u3002\u53ef\u4ee5\u8bc1\u660e\uff0c\u81f3\u5c11\u5b58\u5728\u4e00\u79cd\u7b26\u5408\u8981\u6c42\u7684\u5206\u7ec4\u65b9\u6848\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#1\u3011<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u8f93\u5165#1<\/td><td>\u8f93\u51fa#1<\/td><\/tr><tr><td>7<br>1 3 5 7 9 11 13<\/td><td>3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#2\u3011<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u8f93\u5165#2<\/td><td>\u8f93\u51fa#2<\/td><\/tr><tr><td>7<br>8 2 16 12 1 15 4<\/td><td>5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#3\u3011<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u8f93\u5165#3<\/td><td>\u8f93\u51fa#3<\/td><\/tr><tr><td>6<br>1 2 3 4 5 6<\/td><td>6<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u3010\u8bf4\u660e\u63d0\u793a\u3011<\/p>\n\n\n\n<p>\u6837\u4f8b1\u89e3\u91ca\uff0c\u4ee5\u4e0b\u662f\u4e00\u79cd\u5206\u6210\u6700\u5927\u7ec4\u6570\u4e09\u7ec4\u7684\u65b9\u6848\u3002\u5c06 1 \u548c 3 \u5206\u5728\u7b2c\u4e00\u7ec4\uff0c5\u30017 \u548c 9 \u5206\u5728\u7b2c\u4e8c\u7ec4\uff0c11 \u548c 13 \u5206\u5728\u7b2c\u4e09\u7ec4\u3002<\/p>\n\n\n\n<p>\u3010\u4ee3\u7801\u6837\u4f8b\u3011<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\n\nint main() {\n\tint odd = 0, even = 0; \/\/\u5947\u6570\u3001\u5076\u6570\n\tint n;\n\tcin &gt;&gt; n;\n\tfor (int i = 1; i &lt;= n; i++) {\n\t\tint x;\n\t\tcin &gt;&gt; x;\n\t\tif (x % 2 == 0) {\n\t\t\teven++;\n\t\t} else {\n\t\t\todd++;\n\t\t}\n\t}\n\tif (odd &lt; even) {\n\t\tcout &lt;&lt; 2 * odd + 1 &lt;&lt; endl;\n\t} else if (odd &gt;= even) {\n\t\tif ((odd - even) % 3 == 0) {\n\t\t\tcout &lt;&lt; 2 * (even + (odd - even) \/ 3) &lt;&lt; endl;\n\t\t} else if ((odd - even) % 3 == 1) {\n\t\t\tcout &lt;&lt; 2 * (even + (odd - even) \/ 3) - 1 &lt;&lt; endl;\n\t\t} else if ((odd - even) % 3 == 2) {\n\t\t\tcout &lt;&lt; 2 * (even + (odd - even) \/ 3) + 1 &lt;&lt; endl;\n\t\t}\n\t}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u9898\u76ee\u63cf\u8ff0\u3011 Farmer John \u6b63\u518d\u4e00\u6b21\u5c1d\u8bd5\u7ed9\u4ed6\u7684\u00a0N\u00a0\u5934\u5976\u725b\u62cd\u7167\uff082\u2264N\u22641000\uff09\u3002 \u6bcf\u5934\u5976\u725b\u6709\u4e00\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[25,26,27],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-oi","tag-25","tag-26","tag-27"],"_links":{"self":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=119"}],"version-history":[{"count":4,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}