{"id":101,"date":"2026-04-06T12:04:22","date_gmt":"2026-04-06T04:04:22","guid":{"rendered":"https:\/\/geocommunity.vip\/?p=101"},"modified":"2026-04-07T10:11:38","modified_gmt":"2026-04-07T02:11:38","slug":"%e7%ac%ac%e5%8d%81%e5%85%ad%e5%b1%8a%e8%93%9d%e6%a1%a5%e6%9d%af%e5%a4%a7%e8%b5%9b%e8%bd%af%e4%bb%b6%e8%b5%9b%e7%9c%81%e8%b5%9bc-c-%e5%a4%a7%e5%ad%a6-b-%e7%bb%84","status":"publish","type":"post","link":"https:\/\/geocommunity.vip\/index.php\/2026\/04\/06\/%e7%ac%ac%e5%8d%81%e5%85%ad%e5%b1%8a%e8%93%9d%e6%a1%a5%e6%9d%af%e5%a4%a7%e8%b5%9b%e8%bd%af%e4%bb%b6%e8%b5%9b%e7%9c%81%e8%b5%9bc-c-%e5%a4%a7%e5%ad%a6-b-%e7%bb%84\/","title":{"rendered":"\u7b2c\u5341\u516d\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u7701\u8d5bC\/C++ \u5927\u5b66 B \u7ec4"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1\u3001\u79fb\u52a8\u8ddd\u79bb<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><br>\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c0f\u660e\u521d\u59cb\u5728\u4e8c\u7ef4\u5e73\u9762\u7684\u539f\u70b9&nbsp;(0,0)\uff0c\u4ed6\u60f3\u524d\u5f80\u5750\u6807&nbsp;(233,666).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u79fb\u52a8\u8fc7\u7a0b\u4e2d\uff0c\u4ed6\u53ea\u80fd\u91c7\u7528\u4ee5\u4e0b\u4e24\u79cd\u79fb\u52a8\u65b9\u5f0f\uff0c\u5e76\u4e14\u8fd9\u4e24\u79cd\u79fb\u52a8\u65b9\u5f0f\u53ef\u4ee5\u4ea4\u66ff\u3001\u4e0d\u9650\u6b21\u6570\u5730\u4f7f\u7528\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6c34\u5e73\u5411\u53f3\u79fb\u52a8\uff0c\u5373\u6cbf\u7740&nbsp;<em>x<\/em>&nbsp;\u8f74\u6b63\u65b9\u5411\u79fb\u52a8\u4e00\u5b9a\u7684\u8ddd\u79bb\u3002<\/li>\n\n\n\n<li>\u6cbf\u7740\u4e00\u4e2a\u5706\u5fc3\u5728\u539f\u70b9&nbsp;(0,0)\u3001\u4ee5\u4ed6\u5f53\u524d\u4f4d\u7f6e\u5230\u539f\u70b9\u7684\u8ddd\u79bb\u4e3a\u534a\u5f84\u7684\u5706\u7684\u5706\u5468\u79fb\u52a8\uff0c\u79fb\u52a8\u65b9\u5411\u4e0d\u9650\uff08\u5373\u987a\u65f6\u9488\u6216\u9006\u65f6\u9488\u79fb\u52a8\u4e0d\u9650\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8fd9\u79cd\u6761\u4ef6\u4e0b\uff0c\u4ed6\u5230\u8fbe\u76ee\u7684\u5730\u6700\u5c11\u79fb\u52a8\u591a\u5c11\u5355\u4f4d\u8ddd\u79bb\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ea\u9700\u8f93\u51fa\u7b54\u6848\u56db\u820d\u4e94\u5165\u5230\u6574\u6570\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"632\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/b27fdba64d666f766a7840d1c93afe69_720-1024x632.jpg\" alt=\"\" class=\"wp-image-102\" style=\"aspect-ratio:1.6202820111095286;width:696px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/b27fdba64d666f766a7840d1c93afe69_720-1024x632.jpg 1024w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/b27fdba64d666f766a7840d1c93afe69_720-300x185.jpg 300w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/b27fdba64d666f766a7840d1c93afe69_720-768x474.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/b27fdba64d666f766a7840d1c93afe69_720.jpg 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;math.h&gt;\nint main(int argc, char *argv&#91;])\n{\n  \/\/ \u5148\u6c42\u51faAC\n  double Ac_dis = pow(pow(233, 2)+pow(666, 2), 0.5);\n  double r = Ac_dis;\n  \/\/ \u63a5\u7740\u6c42\u51faBC\n  double Bc_dis = acos(233 \/ Ac_dis) * r;\n  \/\/ \u56db\u820d\u4e94\u5165\u5e76\u8f93\u51fa\u7ed3\u679c\n  int ans = <strong>(int)<\/strong>(Ac_dis + Bc_dis + 0.5);\n  printf(\"%d\", ans);\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u65e0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2\u3001\u5ba2\u6d41\u91cf\u4e0a\u9650<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u5bb6\u8fde\u9501\u65c5\u9986\u5728\u5168\u56fd\u62e5\u6709&nbsp;2025&nbsp;\u4e2a\u5206\u5e97\uff0c\u5206\u522b\u7f16\u53f7\u4e3a&nbsp;1&nbsp;\u81f3&nbsp;2025\u3002\u968f\u7740\u8282\u65e5\u4e34\u8fd1\uff0c\u603b\u90e8\u51b3\u5b9a\u4e3a\u6bcf\u5bb6\u5206\u5e97\u8bbe\u5b9a\u6bcf\u65e5\u5ba2\u6d41\u91cf\u7684\u4e0a\u9650\uff0c\u5206\u522b\u8bb0\u4f5c&nbsp;<em>A<\/em>1\u200b,<em>A<\/em>2\u200b,\u2026,<em>A<\/em>2025\u200b\u3002\u8fd9\u4e9b\u4e0a\u9650\u5e76\u975e\u968f\u610f\u5206\u914d\uff0c\u800c\u662f\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u7ea6\u675f\u6761\u4ef6\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>A<\/em>1\u200b,<em>A<\/em>2\u200b,\u2026,<em>A<\/em>2025\u200b&nbsp;\u5fc5\u987b\u662f&nbsp;1&nbsp;\u81f3&nbsp;2025&nbsp;\u7684\u4e00\u4e2a\u6392\u5217\uff0c\u5373\u6bcf\u4e2a&nbsp;<em>A<\/em><em>i<\/em>\u200b&nbsp;\u5747\u662f&nbsp;1&nbsp;\u81f3&nbsp;2025&nbsp;\u4e4b\u95f4\u7684\u6574\u6570\uff0c\u4e14\u6240\u6709&nbsp;<em>A<\/em><em>i<\/em>\u200b&nbsp;\u4e92\u4e0d\u76f8\u540c\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u4efb\u610f\u5206\u5e97&nbsp;<em>i<\/em>&nbsp;\u548c&nbsp;<em>j<\/em>\uff081\u2264<em>i<\/em>,<em>j<\/em>\u22642025\uff0c<em>i<\/em>&nbsp;\u53ef\u7b49\u4e8e&nbsp;<em>j<\/em>\uff09\uff0c\u5b83\u4eec\u7684\u5ba2\u6d41\u91cf\u4e0a\u9650&nbsp;<em>A<\/em><em>i<\/em>\u200b&nbsp;\u548c&nbsp;<em>A<\/em><em>j<\/em>\u200b&nbsp;\u7684\u4e58\u79ef\u4e0d\u5f97\u8d85\u8fc7&nbsp;<em>i<\/em><em>j<\/em>+2025\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u7ea6\u675f\u65e8\u5728\u5e73\u8861\u5404\u5206\u5e97\u5ba2\u6d41\u538b\u529b\uff0c\u786e\u4fdd\u670d\u52a1\u8d28\u91cf\u548c\u8fd0\u8425\u7a33\u5b9a\u6027\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\uff0c\u8bf7\u4f60\u8ba1\u7b97\u8fd9\u6837\u7684\u5206\u914d\u65b9\u6848\u7a76\u7adf\u6709\u591a\u5c11\u79cd\u3002\u7531\u4e8e\u7b54\u6848\u53ef\u80fd\u5f88\u5927\uff0c\u4f60\u53ea\u9700\u8f93\u51fa\u5176\u5bf9&nbsp;109+7&nbsp;\u53d6\u4f59\u540e\u7684\u7ed3\u679c\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"1024\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/d078321cfb761c75eb9a327786e263ea_720-1-624x1024.jpg\" alt=\"\" class=\"wp-image-105\" style=\"width:427px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/d078321cfb761c75eb9a327786e263ea_720-1-624x1024.jpg 624w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/d078321cfb761c75eb9a327786e263ea_720-1-183x300.jpg 183w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/d078321cfb761c75eb9a327786e263ea_720-1-768x1260.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/d078321cfb761c75eb9a327786e263ea_720-1-936x1536.jpg 936w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/d078321cfb761c75eb9a327786e263ea_720-1.jpg 1218w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">                                           \uff08\u56fe A\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"1024\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/f1b29e89a49c93d9dc18b07dc3f99d6b_720-1-605x1024.jpg\" alt=\"\" class=\"wp-image-106\" style=\"width:427px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/f1b29e89a49c93d9dc18b07dc3f99d6b_720-1-605x1024.jpg 605w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/f1b29e89a49c93d9dc18b07dc3f99d6b_720-1-177x300.jpg 177w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/f1b29e89a49c93d9dc18b07dc3f99d6b_720-1-768x1299.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/f1b29e89a49c93d9dc18b07dc3f99d6b_720-1-908x1536.jpg 908w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/f1b29e89a49c93d9dc18b07dc3f99d6b_720-1.jpg 1090w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">                                           \uff08\u56fe B\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5217\u51fa\u9898\u76ee\u9650\u5236\u7684\u4e09\u4e2a\u6761\u4ef6\uff0c\u4ecei = j\u65f6\u4f5c\u4e3a\u5207\u5165\u70b9\uff0c\u901a\u8fc7\u89c2\u5bdf\u6700\u7ec8\u5f97\u5230\u7ed3\u8bba\u57281013&lt;=i&lt;=2025\u65f6\uff0cAi = i\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u8ba8\u8bbai \u2260 j\u7684\u60c5\u51b5\uff0c\u5206\u4e3a\u56feB\u6240\u793a\u7684\u4e09\u79cd\u60c5\u51b5\uff0c\u7136\u540e\u6839\u636e\u5df2\u7ecf\u5f97\u5230\u7684\u201c1013&lt;=i&lt;=2025\u65f6\uff0cAi = i\u201d\u7ed3\u8bba\uff0c\u6700\u540e\u5f971&lt;= i &lt;=1012\u65f6\uff0cAi &lt;= i + 1\u7684\u7ed3\u8bba\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;math.h&gt;\n\nint main(int argc, char *argv&#91;])\n{\n  \/\/ \u6216\u8005\u76f4\u63a5\u5b9a\u4e49\uff1along long mod = 1000000007LL;\n  long long mod = 1;\n  for (int i = 0; i &lt; 9; i++) {\n    mod *= 10;\n  }\n  mod += 7;\n\n  long long ans = 1;\n  for (int i = 0; i &lt; 1012; i++) {\n    ans *= 2;\n    <strong>ans %= mod; \/\/ \u5fc5\u987b\u5b9e\u65f6\u53d6\u6a21<\/strong>\n  }\n\n  printf(\"%lld\", ans);\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u7eaf\u6570\u5b66\u95ee\u9898\uff0c\u96be\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3\u3001\u53ef\u5206\u89e3\u7684\u6b63\u6574\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b9a\u4e49\u4e00\u79cd\u7279\u6b8a\u7684\u6574\u6570\u5e8f\u5217\uff1a\u8fd9\u79cd\u5e8f\u5217\u7531<strong>\u8fde\u7eed\u9012\u589e\u7684\u6574\u6570<\/strong>\u7ec4\u6210\uff0c\u5e76\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5e8f\u5217\u957f\u5ea6\u81f3\u5c11\u4e3a&nbsp;3\u3002<\/li>\n\n\n\n<li>\u5e8f\u5217\u4e2d\u7684\u6570\u5b57\u662f\u8fde\u7eed\u9012\u589e\u7684\u6574\u6570\uff08\u5373\u76f8\u90bb\u5143\u7d20\u4e4b\u5dee\u4e3a&nbsp;1\uff09\uff0c\u53ef\u4ee5\u5305\u62ec\u6b63\u6574\u6570\u3001\u8d1f\u6574\u6570\u6216&nbsp;0\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff0c[1,2,3]\u3001[4,5,6,7]&nbsp;\u548c&nbsp;[\u22121,0,1]&nbsp;\u662f\u7b26\u5408\u6761\u4ef6\u7684\u5e8f\u5217\uff0c\u800c&nbsp;[1,2]\uff08\u957f\u5ea6\u4e0d\u8db3\uff09\u548c&nbsp;[1,2,4]\uff08\u4e0d\u8fde\u7eed\uff09\u4e0d\u7b26\u5408\u8981\u6c42\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u7ed9\u5b9a\u4e00\u7ec4\u5305\u542b\u00a0<em>N<\/em>\u00a0\u4e2a<strong>\u6b63\u6574\u6570<\/strong>\u7684\u6570\u636e\u00a0<em>A<\/em>1\u200b,<em>A<\/em>2\u200b,\u2026,<em>AN<\/em>\u200b\u3002\u5982\u679c\u67d0\u4e2a\u00a0<em>Ai<\/em>\u200b\u00a0\u80fd\u591f\u8868\u793a\u4e3a\u7b26\u5408\u4e0a\u8ff0\u6761\u4ef6\u7684\u8fde\u7eed\u6574\u6570\u5e8f\u5217\u4e2d\u6240\u6709\u5143\u7d20\u7684\u548c\uff0c\u5219\u79f0\u00a0<em>Ai<\/em>\u200b\u00a0\u662f\u53ef\u5206\u89e3\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf7\u4f60\u7edf\u8ba1\u8fd9\u7ec4\u6570\u636e\u4e2d\u53ef\u5206\u89e3\u7684\u6b63\u6574\u6570\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"712\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/3e55bbf88c4d001d3f708d0dccc03913_720-1024x712.jpg\" alt=\"\" class=\"wp-image-110\" style=\"width:466px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/3e55bbf88c4d001d3f708d0dccc03913_720-1024x712.jpg 1024w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/3e55bbf88c4d001d3f708d0dccc03913_720-300x209.jpg 300w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/3e55bbf88c4d001d3f708d0dccc03913_720-768x534.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/3e55bbf88c4d001d3f708d0dccc03913_720.jpg 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n\nint main(int argc, char *argv&#91;])\n{\n<strong>  \/* \n  &#91;\u2212(x\u22121),\u2212(x\u22122),...,\u22121,0,1,...,x\u22121,x]\n  \u56e0\u6b64\uff0c\u5728\u7ed9\u5b9a\u7684\u6b63\u6574\u6570\u4e2d\uff0c\u53ea\u67091\u4e0d\u6ee1\u8db3\u6761\u4ef6\n  *\/<\/strong>\n  int N;\n  scanf(\"%d\", &amp;N);\n  \n  int ans = 0;\n  for (int i = 0; i &lt; N; i++) {\n    int A;\n    scanf(\"%d\", &amp;A);\n    if (A != 1) ans++;\n  }\n\n  printf(\"%d\", ans);\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u6b63\u8d1f\u62b5\u6d88\u7684\u601d\u7ef4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4\u3001\u4ea7\u503c\u8c03\u6574<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u504f\u8fdc\u7684\u5c0f\u9547\u4e0a\uff0c\u4e09\u5144\u5f1f\u5171\u540c\u7ecf\u8425\u7740\u4e00\u5bb6\u5c0f\u578b\u77ff\u4e1a\u516c\u53f8\u201c\u5144\u5f1f\u77ff\u4e1a\u201d\u3002\u516c\u53f8\u65d7\u4e0b\u6709\u4e09\u5ea7\u77ff\u5c71\uff1a\u91d1\u77ff\u3001\u94f6\u77ff\u548c\u94dc\u77ff\uff0c\u5b83\u4eec\u7684\u521d\u59cb\u4ea7\u503c\u5206\u522b\u7528\u975e\u8d1f\u6574\u6570&nbsp;<em>A<\/em>\u3001<em>B<\/em>&nbsp;\u548c&nbsp;<em>C<\/em>&nbsp;\u8868\u793a\u3002\u8fd9\u4e9b\u77ff\u5c71\u7684\u4ea7\u51fa\u662f\u5c0f\u9547\u7ecf\u6d4e\u7684\u6838\u5fc3\uff0c\u652f\u6491\u7740\u4e09\u5144\u5f1f\u548c\u8bb8\u591a\u77ff\u5de5\u5bb6\u5ead\u7684\u751f\u8ba1\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u800c\uff0c\u5404\u77ff\u5c71\u7684\u4ea7\u503c\u6ce2\u52a8\u5267\u70c8\uff0c\u6709\u65f6\u91d1\u77ff\u6536\u76ca\u9ad8\u800c\u94f6\u77ff\u3001\u94dc\u77ff\u4f4e\u8ff7\uff0c\u6709\u65f6\u5219\u76f8\u53cd\u3002\u8fd9\u79cd\u4e0d\u7a33\u5b9a\u6027\u8ba9\u516c\u53f8\u6536\u5165\u96be\u4ee5\u9884\u6d4b\uff0c\u4e5f\u5e38\u5f15\u53d1\u5144\u5f1f\u95f4\u7684\u4e89\u6267\u3002\u4e3a\u4e86\u7a33\u5b9a\u7ecf\u8425\uff0c\u4e09\u5144\u5f1f\u8bbe\u8ba1\u4e86\u4e00\u4e2a\u516c\u5e73\u7684\u4ea7\u503c\u8c03\u6574\u7b56\u7565\uff0c\u6bcf\u5e74\u6267\u884c\u4e00\u6b21\uff0c\u6bcf\u6b21\u8c03\u6574\u65f6\uff0c\u5c06\u6839\u636e\u5f53\u524d\u7684\u4ea7\u503c&nbsp;<em>A<\/em>\u3001<em>B<\/em>\u3001<em>C<\/em>\uff0c\u8ba1\u7b97\u65b0\u4ea7\u503c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u91d1\u77ff\u65b0\u4ea7\u503c&nbsp;<em>A<\/em>\u2032=\u230a2<em>B<\/em>+<em>C<\/em>\u200b\u230b\uff1b<\/li>\n\n\n\n<li>\u94f6\u77ff\u65b0\u4ea7\u503c&nbsp;<em>B<\/em>\u2032=\u230a2<em>A<\/em>+<em>C<\/em>\u200b\u230b\uff1b<\/li>\n\n\n\n<li>\u94dc\u77ff\u65b0\u4ea7\u503c&nbsp;<em>C<\/em>\u2032=\u230a2<em>A<\/em>+<em>B<\/em>\u200b\u230b\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\uff0c<math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mo stretchy=\"false\">\u230a<\/mo><mo stretchy=\"false\">\u230b<\/mo><\/mrow><\/semantics><\/math>\u230a\u230b&nbsp;\u8868\u793a\u5411\u4e0b\u53d6\u6574\u3002\u4f8b\u5982\uff0c\u230a3.7\u230b=3\uff0c\u230a5.2\u230b=5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba1\u7b97\u51fa&nbsp;<em>A<\/em>\u2032\u3001<em>B<\/em>\u2032\u3001<em>C<\/em>\u2032&nbsp;\u540e\uff0c\u540c\u65f6\u66f4\u65b0\uff1a<em>A<\/em>&nbsp;\u53d8\u4e3a&nbsp;<em>A<\/em>\u2032\uff0c<em>B<\/em>&nbsp;\u53d8\u4e3a&nbsp;<em>B<\/em>\u2032\uff0c<em>C<\/em>&nbsp;\u53d8\u4e3a&nbsp;<em>C<\/em>\u2032\uff0c\u4f5c\u4e3a\u4e0b\u4e00\u5e74\u8c03\u6574\u7684\u57fa\u7840\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e09\u5144\u5f1f\u8ba4\u4e3a\u8fd9\u4e2a\u65b9\u6cd5\u80fd\u5e73\u8861\u4ea7\u503c\u6ce2\u52a8\uff0c\u4e8e\u662f\u8ba1\u5212\u8fde\u7eed\u6267\u884c&nbsp;<em>K<\/em>&nbsp;\u6b21\u8c03\u6574\u3002\u73b0\u5728\uff0c\u8bf7\u4f60\u5e2e\u4ed6\u4eec\u8ba1\u7b97\uff0c\u7ecf\u8fc7&nbsp;<em>K<\/em>&nbsp;\u6b21\u8c03\u6574\u540e\uff0c\u91d1\u77ff\u3001\u94f6\u77ff\u548c\u94dc\u77ff\u7684\u4ea7\u503c\u5206\u522b\u662f\u591a\u5c11\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6a21\u62df+\u526a\u679d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n\nint main(int argc, char *argv&#91;])\n{\n  int T;\n  scanf(\"%d\", &amp;T);\n  for (int i = 0; i &lt; T; i++) {\n    \/\/ \u8f93\u5165\n    int A, B, C, K;\n    scanf(\"%d\", &amp;A);\n    scanf(\"%d\", &amp;B);\n    scanf(\"%d\", &amp;C);\n    scanf(\"%d\", &amp;K);\n    \/\/ \u8ba1\u7b97\n    int A_n, B_n, C_n;\n    for (int j = 0; j &lt; K; j++) {\n      A_n = (B + C) \/ 2;\n      B_n = (A + C) \/ 2;\n      C_n = (A + B) \/ 2;\n<strong>      \/\/ \u526a\u679d\uff0c\u72b6\u6001\u672a\u53d8\u5219\u9000\u51fa\n      if (A_n == A &amp;&amp; B_n == B &amp;&amp; C_n == C) break;<\/strong>\n      A = A_n;\n      B = B_n;\n      C = C_n;\n    }\n    \/\/ \u8f93\u51fa\n    printf(\"%d %d %d\\n\", A, B, C);\n  }\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u526a\u679d\uff0c\u548cA B C\u53d8\u5316\u7684\u8d8b\u52bf\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5\u3001<strong>\u753b\u5c55\u5e03\u7f6e<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u753b\u5c55\u7b56\u5c55\u4eba\u5c0f\u84dd\u548c\u52a9\u7406\u5c0f\u6865\u4e3a\u5373\u5c06\u4e3e\u529e\u7684\u753b\u5c55\u51c6\u5907\u4e86&nbsp;<em>N<\/em>&nbsp;\u5e45\u753b\u4f5c\uff0c\u5176\u827a\u672f\u4ef7\u503c\u5206\u522b\u4e3a&nbsp;<em>A<\/em>1\u200b,<em>A<\/em>2\u200b,\u2026,<em>A<\/em><em>N<\/em>\u200b\u3002\u4ed6\u4eec\u9700\u8981\u4ece\u8fd9&nbsp;<em>N<\/em>&nbsp;\u5e45\u753b\u4e2d\u6311\u9009&nbsp;<em>M<\/em>&nbsp;\u5e45\uff0c\u5e76\u6309\u7167\u4e00\u5b9a\u987a\u5e8f\u5e03\u7f6e\u5728\u5c55\u5385\u7684&nbsp;<em>M<\/em>&nbsp;\u4e2a\u4f4d\u7f6e\u4e0a\u3002\u5982\u679c\u968f\u610f\u6311\u9009\u548c\u6392\u5217\uff0c\u827a\u672f\u4ef7\u503c\u7684\u53d8\u5316\u53ef\u80fd\u4f1a\u8fc7\u4e8e\u7a81\u5140\uff0c\u5bfc\u81f4\u89c2\u4f17\u7684\u89c2\u5c55\u4f53\u9a8c\u4e0d\u591f\u6d41\u7545\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u4f18\u5316\u5e03\u7f6e\uff0c\u4ed6\u4eec\u67e5\u9605\u4e86\u300a\u753b\u5c55\u5e03\u7f6e\u6307\u5357\u300b\u3002\u6307\u5357\u6307\u51fa\uff0c\u7406\u60f3\u7684\u753b\u5c55\u5e94\u4f7f\u89c2\u4f17\u5728\u6b23\u8d4f\u753b\u4f5c\u65f6\uff0c\u827a\u672f\u4ef7\u503c\u7684\u8fc7\u6e21\u5c3d\u91cf\u5e73\u7f13\u3002\u6307\u5357\u5efa\u8bae\uff0c\u9009\u62e9\u5e76\u6392\u5217\u00a0<em>M<\/em>\u00a0\u5e45\u753b\uff0c\u5e94\u4f7f\u827a\u672f\u4ef7\u503c\u7684\u53d8\u5316\u7a0b\u5ea6\u901a\u8fc7\u4e00\u4e2a\u6570\u503c\u00a0<em>L<\/em>\u00a0\u6765\u8861\u91cf\uff0c\u4e14<strong>\u8be5\u503c\u8d8a\u5c0f\u8d8a\u597d<\/strong>\u3002\u6570\u503c\u00a0<em>L<\/em>\u00a0\u7684\u5b9a\u4e49\u4e3a\uff1a<math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\" display=\"block\"><semantics><mrow><mi>L<\/mi><mo>=<\/mo><munderover><mo>\u2211<\/mo><mrow><mi>i<\/mi><mo>=<\/mo><mn>1<\/mn><\/mrow><mrow><mi>M<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/munderover><mi mathvariant=\"normal\">\u2223<\/mi><msubsup><mi>B<\/mi><mrow><mi>i<\/mi><mo>+<\/mo><mn>1<\/mn><\/mrow><mn>2<\/mn><\/msubsup><mo>\u2212<\/mo><msubsup><mi>B<\/mi><mi>i<\/mi><mn>2<\/mn><\/msubsup><mi mathvariant=\"normal\">\u2223<\/mi><\/mrow><\/semantics><\/math>\u5176\u4e2d\u00a0<em>Bi<\/em>\u200b\u00a0\u8868\u793a\u5c55\u5385\u7b2c\u00a0<em>i<\/em>\u00a0\u4e2a\u4f4d\u7f6e\u4e0a\u753b\u4f5c\u7684\u827a\u672f\u4ef7\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\uff0c\u4ed6\u4eec\u5e0c\u671b\u901a\u8fc7\u7cbe\u5fc3\u6311\u9009\u548c\u6392\u5217\u8fd9&nbsp;<em>M<\/em>&nbsp;\u5e45\u753b\u4f5c\uff0c\u4f7f&nbsp;<em>L<\/em>&nbsp;\u8fbe\u5230\u6700\u5c0f\u503c\uff0c\u4ee5\u63d0\u5347\u753b\u5c55\u7684\u6574\u4f53\u534f\u8c03\u6027\u3002\u8bf7\u4f60\u5e2e\u4ed6\u4eec\u8ba1\u7b97\u51fa\u8fd9\u4e2a\u6700\u5c0f\u503c\u662f\u591a\u5c11\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u5047\u8bbeM = 3,\u7136\u540e\u628aL\u516c\u5f0f\u5c55\u5f00\u770b\u4e0b\uff0c\u54e6\uff0c\u53d1\u73b0\u662f\u6c42\u76f8\u90bb\u5143\u7d20\u5e73\u65b9\u5dee\u4e4b\u548c\u6700\u5c0f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u4e00\u5b9a\u8981\u6392\u5e8f\u4e14\u76f8\u90bb\uff0c\uff08\u5176\u5b9e\u6392\u5e8f\u5c31\u662f\u4e3a\u4e86\u76f8\u90bb\uff09\uff0c\u4f46\u662f\u662f\u54ea\u4e09\u4e2a\u76f8\u90bb\u7684\u5462\uff1f\u90a3\u4e48\u5c31\u9700\u8981\u6ed1\u52a8\u7a97\u53e3\u4e0d\u65ad\u66f4\u65b0\u7b54\u6848\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"1024\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/69ad416ea04d191f4d0d4dbb80ac72cd_720-594x1024.jpg\" alt=\"\" class=\"wp-image-114\" style=\"aspect-ratio:0.5800961894191639;width:423px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/69ad416ea04d191f4d0d4dbb80ac72cd_720-594x1024.jpg 594w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/69ad416ea04d191f4d0d4dbb80ac72cd_720-174x300.jpg 174w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/69ad416ea04d191f4d0d4dbb80ac72cd_720-768x1324.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/69ad416ea04d191f4d0d4dbb80ac72cd_720-891x1536.jpg 891w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/69ad416ea04d191f4d0d4dbb80ac72cd_720.jpg 1008w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#define MIN(a, b) ((a) > (b) ? b : a)\n\/\/ cmp\u8fd4\u56de\u7c7b\u578b\u4e00\u5b9a\u662fint\n<strong>int<\/strong> cmp(const void* a, const void* b) {\n  <strong>long long<\/strong> n = (*(long long *)a);\n  long long m = (*(long long *)b);\n  if (n > m) return 1;\n  if (n &lt; m) return -1;\n  return 0;\n}\nint main(int argc, char *argv&#91;])\n{ \n  \/\/ 1 \u8f93\u5165\n  int N, M;\n  scanf(\"%d %d\", &amp;N, &amp;M);\n  long long arr&#91;N];\n  for (int i = 0; i &lt; N; i++) {\n    scanf(\"%lld\", &amp;arr&#91;i]);\n    arr&#91;i] = arr&#91;i]*arr&#91;i];\n  }\n  \/\/ 2 \u6392\u5e8f\n  <strong>qsort(arr, N, sizeof(long long), cmp);<\/strong>\n  \/\/ 3 \u6ed1\u52a8\u7a97\u53e3\uff0c\u66f4\u65b0\u7b54\u6848\uff0c\u7a97\u53e3\u5927\u5c0f\u4e3aM\n  long long ans = arr&#91;N-1] - arr&#91;0] + 1; \/\/ \u5df2\u77e5\u8be5\u9898\u4e00\u5b9a\u6709\u7b54\u6848\uff0c\u5148\u521d\u59cb\u5316\u4e00\u4e2a\u4e0d\u53ef\u80fd\u7684\u7b54\u6848\n  for (int i = 0; i + M &lt;= N; i++) {\n    ans = MIN(ans, arr&#91;i+M-1] - arr&#91;i]);\n  }\n  \/\/ 4 \u8f93\u51fa\u7b54\u6848\n  printf(\"%lld\", ans);\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u6ed1\u52a8\u7a97\u53e3\uff0c\u4e0d\u65ad\u66f4\u65b0\u7b54\u6848\u3002\u4e14&#8221;\u5bf9\u4e8e\u6240\u6709\u8bc4\u6d4b\u7528\u4f8b\uff0c2\u2264<em>M<\/em>\u2264<em>N<\/em>\u2264105\uff0c1\u2264<em>A<\/em><em>i<\/em>\u200b\u2264105\u3002&#8221;\uff0c\u6240\u4ee5\u8981\u7528long long\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6\u3001\u6c34\u8d28\u68c0\u6d4b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c0f\u660e\u9700\u8981\u5728\u4e00\u6761&nbsp;2\u00d7<em>n<\/em>&nbsp;\u7684\u6cb3\u5e8a\u4e0a\u94fa\u8bbe\u6c34\u8d28\u68c0\u6d4b\u5668\u3002\u5728\u4ed6\u94fa\u8bbe\u4e4b\u524d\uff0c\u6cb3\u5e8a\u4e0a\u5df2\u7ecf\u5b58\u5728\u4e00\u4e9b\u68c0\u6d4b\u5668\u3002\u5982\u679c\u4e24\u4e2a\u68c0\u6d4b\u5668\u4e0a\u4e0b\u6216\u5de6\u53f3\u76f8\u90bb\uff0c\u90a3\u4e48\u8fd9\u4e24\u4e2a\u68c0\u6d4b\u5668\u5c31\u662f\u4e92\u76f8\u8fde\u901a\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fde\u901a\u5177\u6709\u4f20\u9012\u6027\uff0c\u5373\u5982\u679c&nbsp;<em>A<\/em>&nbsp;\u548c&nbsp;<em>B<\/em>&nbsp;\u8fde\u901a\uff0c<em>B<\/em>&nbsp;\u548c&nbsp;<em>C<\/em>&nbsp;\u8fde\u901a\uff0c\u90a3\u4e48&nbsp;<em>A<\/em>&nbsp;\u548c&nbsp;<em>C<\/em>&nbsp;\u4e5f\u8fde\u901a\u3002\u73b0\u5728\u4ed6\u9700\u8981\u5728\u6cb3\u5e8a\u4e0a\u589e\u52a0\u94fa\u8bbe\u4e00\u4e9b\u68c0\u6d4b\u5668\uff0c\u4f7f\u5f97\u6240\u6709\u68c0\u6d4b\u5668\u90fd\u4e92\u76f8\u8fde\u901a\u3002\u4ed6\u60f3\u77e5\u9053\u6700\u5c11\u9700\u8981\u589e\u52a0\u94fa\u8bbe\u591a\u5c11\u4e2a\u68c0\u6d4b\u5668\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Dijkstra<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;string.h>\n\n#define MAXN 1000005\n<strong>#define INF 0x3f3f3f3f<\/strong>\n\n\/\/ \u5b58\u50a8\u70b9\ntypedef struct {\n  int r, c;\n} PII;\n\n\/\/ \u5168\u5c40\u53d8\u91cf\uff0c\u9632\u6b62\u6808\u6ea2\u51fa\nchar s&#91;2]&#91;MAXN];\nint dist&#91;2]&#91;MAXN]; \/\/ dist&#91;i]&#91;j]\u8868\u793a\u5230\u8fbe\u70b9(i,j)\u7684\u6700\u77ed\u8def\u5f84\nint st&#91;2]&#91;MAXN]; \/\/ \u6807\u8bb0\u6570\u7ec4\uff0c\u8868\u793a\u70b9(i,j)\u5df2\u627e\u5230\u6700\u77ed\u8def\u5f84\nint n;\n\n\/\/ \u624b\u5199\u53cc\u7aef\u961f\u5217\n<strong>PII deque&#91;MAXN * 4];<\/strong>\n<strong>int head = MAXN * 2, tail = MAXN * 2;<\/strong>\n\n\nvoid push_front(int r, int c) {\n  deque&#91;<strong>--head<\/strong>] = <strong>(PII){r, c}<\/strong>;\n}\n\nvoid push_back(int r, int c) {\n    deque&#91;<strong>tail++<\/strong>] = <strong>(PII){r, c}<\/strong>;\n}\n\nPII pop_front() {\n    return deque&#91;head++];\n}\n\nint is_empty() {\n    return head == tail;\n}\n\n\/\/ 0-1BFS\uff1adijkstra\nint main(int argc, char *argv&#91;])\n{\n  \/\/ \u6570\u636e\u8bfb\u5165\n  scanf(\"%s %s\", s&#91;0], s&#91;1]);\n  n = strlen(s&#91;0]);\n\n  \/\/ \u6570\u7ec4\u521d\u59cb\u5316\n  <strong>memset(dist, 0x3f, sizeof(dist));<\/strong>\n  memset(st, 0, sizeof(st));\n\n  \/\/ \u5bfb\u627e\u7b2c\u4e00\u4e2a'#'\u4f5c\u4e3a\u6e90\u70b9\n  int start_r = -1, start_c = -1;\n  for (int j = 0; j &lt; n; j++) {\n    if (s&#91;0]&#91;j] == '#') {\n      start_r = 0;\n      start_c = j;\n      break;\n    }\n    if (s&#91;1]&#91;j] == '#') {\n      start_r = 1;\n      start_c = j;\n      break;\n    }\n  }\n\n  \/\/ \u526a\u679d\n  if (start_r == -1) {\n    printf(\"0\\n\");\n    return 0;\n  }\n\n  \/\/ 0-1 BFS\n  dist&#91;start_r]&#91;start_c] = 0;\n  push_back(start_r, start_c);\n\n  int dx&#91;] = {0, 0, 1, -1};\n  int dy&#91;] = {1, -1, 0, 0};\n  int max_dis = 0;\n\n  while (!is_empty()) {\n    PII t = pop_front();\n    int r = t.r, c = t.c;\n\n    if (st&#91;r]&#91;c]) continue;\n    st&#91;r]&#91;c] = 1; \/\/ \u6807\u8bb0(r, c)\u70b9\u5df2\u83b7\u53d6\u5230\u6700\u77ed\u8def\u5f84\n\n    if (s&#91;r]&#91;c] == '#') {\n      max_dis = dist&#91;r]&#91;c]; \/\/ \u66f4\u65b0\u7b54\u6848\n    }\n\n    for (int i = 0; i &lt; 4; i++) {\n      int nr = r + dx&#91;i];\n      int nc = c + dy&#91;i];\n\n      if (nr >= 0 &amp;&amp; nr &lt; 2 &amp;&amp; nc >= 0 &amp;&amp; nc &lt; n) {\n        int w = (s&#91;nr]&#91;nc] == '#' ? 0 : 1);\n        if (dist&#91;nr]&#91;nc] > dist&#91;r]&#91;c] + w) {\n          dist&#91;nr]&#91;nc] = dist&#91;r]&#91;c] + w;\n<strong>          if (w == 0) push_front(nr, nc);\n          else push_back(nr, nc);<\/strong>\n        }\n      } \n    }\n  }\n\n  \/\/ \u8f93\u51fa\n  printf(\"%d\\n\", max_dis);\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u5b8c\u5168\u60f3\u4e0d\u5230\uff0c\u60f3\u5230\u4e5f\u4e0d\u4f1a\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7\u3001\u751f\u6210\u8f66\u95f4<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c0f\u660e\u6b63\u5728\u6539\u9020\u4e00\u4e2a\u751f\u4ea7\u8f66\u95f4\u7684\u751f\u4ea7\u6d41\u6c34\u7ebf\u3002\u8fd9\u4e2a\u8f66\u95f4\u5171\u6709&nbsp;<em>n<\/em>&nbsp;\u53f0\u8bbe\u5907\uff0c\u6784\u6210\u4ee5&nbsp;1&nbsp;\u4e3a\u6839\u7ed3\u70b9\u7684\u4e00\u68f5\u6811\uff0c\u7ed3\u70b9&nbsp;<em>i<\/em>&nbsp;\u6709\u6743\u503c&nbsp;<em>w<\/em><em>i<\/em>\u200b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\uff0c\u53f6\u7ed3\u70b9\u7684\u6743\u503c&nbsp;<em>w<\/em><em>i<\/em>\u200b&nbsp;\u8868\u793a\u6bcf\u5355\u4f4d\u65f6\u95f4\u4ea7\u51fa&nbsp;<em>w<\/em><em>i<\/em>\u200b&nbsp;\u5355\u4f4d\u6750\u6599\u5e76\u9001\u5f80\u7236\u7ed3\u70b9\uff1b\u6839\u7ed3\u70b9\u7684\u6743\u503c&nbsp;<em>w<\/em><em>i<\/em>\u200b&nbsp;\u8868\u793a\u6bcf\u5355\u4f4d\u65f6\u95f4\u5185\u80fd\u6253\u5305&nbsp;<em>w<\/em><em>i<\/em>\u200b&nbsp;\u5355\u4f4d\u6210\u54c1\uff1b \u5176\u4ed6\u7ed3\u70b9\u7684\u6743\u503c&nbsp;<em>w<\/em><em>i<\/em>\u200b&nbsp;\u8868\u793a\u6bcf\u5355\u4f4d\u65f6\u95f4\u6700\u591a\u80fd\u52a0\u5de5&nbsp;<em>w<\/em><em>i<\/em>\u200b&nbsp;\u5355\u4f4d\u6750\u6599\u5e76\u9001\u5f80\u7236\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u4e8e\u751f\u4ea7\u7ebf\u4e2d\u67d0\u4e9b\u7ed3\u70b9\u4ea7\u80fd\u4e0d\u8db3\uff0c\u5bfc\u81f4\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\uff0c\u5373\u67d0\u4e9b\u7ed3\u70b9\u6bcf\u5355\u4f4d\u65f6\u95f4\u6536\u5230\u7684\u6750\u6599\u8d85\u8fc7\u5176\u52a0\u5de5\u80fd\u529b\u4e0a\u9650\u3002\u5c0f\u660e\u8ba1\u5212\u5220\u9664\u4e00\u4e9b\u7ed3\u70b9\u4f7f\u6240\u6709\u7ed3\u70b9\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u60f3\u77e5\u9053\u5220\u9664\u540e<strong>\u6839\u7ed3\u70b9\u6bcf\u5355\u4f4d\u65f6\u95f4\u6700\u591a\u80fd\u6253\u5305\u591a\u5c11\u5355\u4f4d\u6210\u54c1<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DFS+DP\uff0c\u6811\u5f62DP\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"898\" height=\"1024\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/0a1d50a31c53c2e0e92b7d82b6418591_720-898x1024.jpg\" alt=\"\" class=\"wp-image-118\" style=\"aspect-ratio:0.876955450793599;width:459px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/0a1d50a31c53c2e0e92b7d82b6418591_720-898x1024.jpg 898w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/0a1d50a31c53c2e0e92b7d82b6418591_720-263x300.jpg 263w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/0a1d50a31c53c2e0e92b7d82b6418591_720-768x876.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/0a1d50a31c53c2e0e92b7d82b6418591_720.jpg 1280w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;string.h>\n\n#define MAXN 1005\n#define MAXW 1005\n\nint n;\nint w&#91;MAXN]; \/\/ w&#91;i]\u8868\u793a\u8282\u70b9i\u5355\u4f4d\u65f6\u95f4\u80fd\u627f\u53d7\u5355\u4f4d\u6750\u6599\u7684\u6700\u5927\u503c\nint adj&#91;MAXN]&#91;MAXN]; \/\/ adj&#91;i]&#91;j]\u8868\u793a\u8282\u70b9j\u662f\u5426\u4e3a\u8282\u70b9i\u7684\u5b50\u8282\u70b9\uff08\u8f93\u5165\u7684\u7b2c\u4e00\u4e2a\u662f\u7236\u8282\u70b9\uff0c\u6240\u4ee5\u5355\u5411\u5b58\u50a8\u5373\u53ef\uff09\nint dp&#91;MAXN]&#91;MAXW]; \/\/ dp&#91;i]&#91;j]\u8868\u793a\u8282\u70b9i\u80fd\u5426\u5728\u5355\u4f4d\u65f6\u95f4\u5411\u4e0a\u62ffj\u5355\u4f4d\u6750\u6599\n\nint temp&#91;MAXW];\n\nvoid dfs(u, fa)\n{\n  int is_leaf = 1;\n  \/\/ \u521d\u59cb\u5316\n  dp&#91;u]&#91;0] = 1;\n  \/\/ \u6838\u5fc3\n  <strong>for (int v = 1; v &lt;= n; v++) {\n    if (adj&#91;u]&#91;v]) {\n      is_leaf = 0;\n      dfs(v, u);\n      memset(temp, 0, sizeof(temp));\n\n      for (int i = 0; i &lt;= w&#91;u]; i++) {\n        if (dp&#91;u]&#91;i] == 1) {\n          for (int j = 0; j &lt;= w&#91;v]; j++) {\n            if (dp&#91;v]&#91;j] == 1 &amp;&amp; i + j &lt;= w&#91;u]) {\n              temp&#91;i + j] = 1;\n            }\n          }\n        }\n      }\n\n      \/\/ \u5b58\u50a8\u7ed3\u679c\n      for (int i = 0; i &lt;= w&#91;u]; i++) {\n        dp&#91;u]&#91;i] = temp&#91;i]; \/\/ \u4e0d\u65ad\u5b8c\u5584dp&#91;u]\u4e2d\n      }\n    } \n  }\n  if (is_leaf) {\n    dp&#91;u]&#91;0] = 1;\n    dp&#91;u]&#91;w&#91;u]] = 1;\n  }<\/strong>\n}\n\nint main(int argc, char *argv&#91;])\n{\n  \/\/ 1 \u8f93\u5165\n  scanf(\"%d\", &amp;n);\n  for (int i = 1; i &lt;= n; i++) {\n    scanf(\"%d\", &amp;w&#91;i]);\n  }\n  for (int i = 0; i &lt; n - 1; i++) {\n    int u, v;\n    scanf(\"%d %d\", &amp;u, &amp;v);\n    adj&#91;u]&#91;v] = 1;\n  }\n  \/\/ 2 DFS\u6784\u9020dp\u6570\u7ec4\n  dfs(1, 0);\n  \/\/ 3 \u8f93\u51fa\u7b54\u6848\n  int ans;\n  for (int x = w&#91;1]; x >= 0; x--) {\n    if (dp&#91;1]&#91;x] == 1) {\n      ans = x;\n      break;\n    }\n  }\n  printf(\"%d\\n\", ans);\n  return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u5b8c\u5168\u60f3\u4e0d\u5230\uff0c\u60f3\u5230\u4e5f\u4e0d\u4f1a\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">8\u3001\u88c5\u4fee\u62a5\u4ef7<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8001\u738b\u8ba1\u5212\u88c5\u4fee\u623f\u5b50\uff0c\u4e8e\u662f\u8054\u7cfb\u4e86\u4e00\u5bb6\u88c5\u4fee\u516c\u53f8\u3002\u8be5\u516c\u53f8\u6709\u4e00\u5957\u81ea\u52a8\u62a5\u4ef7\u7cfb\u7edf\uff0c\u53ea\u9700\u7528\u6237\u63d0\u4f9b&nbsp;<em>N<\/em>&nbsp;\u9879\u88c5\u4fee\u76f8\u5173\u8d39\u7528&nbsp;<em>A<\/em>1\u200b,<em>A<\/em>2\u200b,\u2026,<em>A<\/em><em>N<\/em>\u200b\uff0c\u7cfb\u7edf\u4fbf\u4f1a\u6839\u636e\u8fd9\u4e9b\u8d39\u7528\u751f\u6210\u6700\u7ec8\u7684\u62a5\u4ef7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u800c\uff0c\u5f53\u8001\u738b\u63d0\u4ea4\u6570\u636e\u540e\uff0c\u4ed6\u53d1\u73b0\u8fd9\u5957\u7cfb\u7edf\u7684\u8fd0\u4f5c\u65b9\u5f0f\u5e76\u4e0d\u900f\u660e\uff1a\u7cfb\u7edf\u53ea\u4f1a\u7ed9\u51fa\u4e00\u4e2a\u6700\u7ec8\u62a5\u4ef7\uff0c\u800c\u4e0d\u4f1a\u516c\u5f00\u4efb\u4f55\u8fd0\u7b97\u8fc7\u7a0b\u6216\u4e2d\u95f4\u6b65\u9aa4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u53f8\u5bf9\u6b64\u89e3\u91ca\u79f0\uff0c\u8fd9\u5957\u7cfb\u7edf\u4f1a\u4f9d\u636e\u67d0\u79cd\u5185\u90e8\u7b97\u6cd5\uff0c\u5728\u6bcf\u5bf9\u76f8\u90bb\u6570\u5b57\u4e4b\u95f4\u63d2\u5165&nbsp;+\uff08\u52a0\u6cd5\uff09\u3001\u2212\uff08\u51cf\u6cd5\uff09\u6216&nbsp;\u2295\uff08\u5f02\u6216\uff09\u8fd0\u7b97\u7b26\uff0c\u5e76\u6309\u7167\u7279\u5b9a\u4f18\u5148\u7ea7\u89c4\u5219\u8ba1\u7b97\u603b\u548c\uff1a<strong>\u5f02\u6216\u8fd0\u7b97\u4f18\u5148\u7ea7\u6700\u9ad8\uff0c\u5176\u6b21\u662f\u52a0\u51cf\u3002<\/strong>\u4f46\u7531\u4e8e\u4fdd\u5bc6\u6027\uff0c\u5177\u4f53\u7684\u8fd0\u7b97\u7b26\u7ec4\u5408\u4ee5\u53ca\u4e2d\u95f4\u8fc7\u7a0b\u90fd\u4e0d\u4f1a\u5bf9\u5916\u516c\u5f00\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u9a8c\u8bc1\u7cfb\u7edf\u62a5\u4ef7\u662f\u5426\u5408\u7406\uff0c\u8001\u738b\u51b3\u5b9a\u6a21\u62df\u5176\u8fd0\u4f5c\u65b9\u5f0f\uff0c\u5c1d\u8bd5\u6bcf\u79cd\u53ef\u80fd\u7684\u8fd0\u7b97\u7b26\u7ec4\u5408\uff0c\u8ba1\u7b97\u51fa\u6240\u6709\u53ef\u80fd\u51fa\u73b0\u7684\u603b\u548c\u3002\u5982\u679c\u6700\u7ec8\u62a5\u4ef7\u660e\u663e\u8d85\u51fa\u8fd9\u4e2a\u8303\u56f4\uff0c\u4ed6\u5c31\u6709\u7406\u7531\u6000\u7591\u7cfb\u7edf\u5b58\u5728\u5f02\u5e38\u6216\u8bef\u5dee\u3002\u53ea\u662f\u8001\u738b\u5e74\u4e8b\u5df2\u9ad8\uff0c\u624b\u52a8\u8ba1\u7b97\u9887\u4e3a\u5403\u529b\uff0c\u4fbf\u5411\u4f60\u6c42\u52a9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\uff0c\u8bf7\u4f60\u5e2e\u8001\u738b\u7b97\u51fa\u6240\u6709\u53ef\u80fd\u7684\u603b\u548c\u3002\u7531\u4e8e\u8be5\u603b\u548c\u53ef\u80fd\u5f88\u5927\uff0c\u4f60\u53ea\u9700\u63d0\u4f9b\u5176\u5bf9&nbsp;109+7&nbsp;\u53d6\u4f59\u540e\u7684\u7ed3\u679c\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09\u89e3\u9898\u601d\u8def<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u4e8e<strong>\u5f02\u6216\u4f18\u5148\u7ea7\u6700\u9ad8<\/strong>\uff0c\u6574\u4e2a\u8868\u8fbe\u5f0f\u88ab\u52a0\u51cf\u53f7\u5207\u5206\u6210\u591a\u4e2a\u201c\u5f02\u6216\u5757\u201d\uff0c\u800c\u5728\u6c42\u6240\u6709\u7ec4\u5408\u603b\u548c\u65f6\uff0c<strong>\u52a0\u51cf\u53f7\u540e\u7684\u6240\u6709\u540e\u7eed\u53d8\u5316\u90fd\u4f1a\u56e0\u6b63\u8d1f\u5bf9\u79f0\u800c\u76f8\u4e92\u62b5\u6d88\u4e3a 0<\/strong>\uff0c\u56e0\u6b64\u53ea\u9700\u904d\u5386\u6bcf\u4e00\u4e2a\u53ef\u80fd\u6210\u4e3a\u201c\u7b2c\u4e00\u4e2a\u52a0\u51cf\u53f7\u524d\u7f00\u201d\u7684\u5f02\u6216\u5757 s\uff0c\u8ba1\u7b97\u5b83\u5728\u6240\u6709\u53ef\u80fd\u7ec4\u5408\u4e2d\u7684\u8d21\u732e\uff0c\u6700\u540e\u7d2f\u52a0\u4e0a\u552f\u4e00\u7684\u201c\u5168\u5f02\u6216\u201d\u60c5\u51b5\u5373\u53ef\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"562\" height=\"1024\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/27f7068202c6a9c5d136f0433d9b0184_720-562x1024.jpg\" alt=\"\" class=\"wp-image-120\" style=\"aspect-ratio:0.5488339606534477;width:404px;height:auto\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/27f7068202c6a9c5d136f0433d9b0184_720-562x1024.jpg 562w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/27f7068202c6a9c5d136f0433d9b0184_720-165x300.jpg 165w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/27f7068202c6a9c5d136f0433d9b0184_720-768x1399.jpg 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/27f7068202c6a9c5d136f0433d9b0184_720-843x1536.jpg 843w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/27f7068202c6a9c5d136f0433d9b0184_720.jpg 1092w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\n#define MOD 1000000007\n\nint main() {\n    \/\/ 1 \u8f93\u5165\n    int n;\n    scanf(\"%d\", &amp;n);\n\n    int a&#91;n + 1];\n    for (int i = 1; i &lt;= n; i++) {\n        scanf(\"%d\", &amp;a&#91;i]);\n    }\n\n    \/\/ \u9884\u5904\u7406\u6570\u7ec4\n    long long mi&#91;n + 1];\n    mi&#91;0] = 1;\n    for (int i = 1; i &lt;= n; i++) {\n        mi&#91;i] = (mi&#91;i - 1] * 3) % MOD;\n    }\n\n    \/\/ 2 \u6570\u5b66\u903b\u8f91\n    long long ret = 0;\n    long long s = 0;\n\n    for (int i = 1; i &lt; n; i++) {\n        s ^= a&#91;i];\n        \n        long long contribution = (s * 2) % MOD;\n        contribution = (contribution * mi&#91;n - i - 1]) % MOD;\n        \n        ret = (ret + contribution) % MOD;\n    }\n\n    s ^= a&#91;n];\n    ret = (ret + s) % MOD;\n\n    printf(\"%lld\\n\", ret % MOD);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09\u96be\u70b9\uff1a\u6570\u5b66\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"682\" src=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/QQ_1775471001741-1024x682.png\" alt=\"\" class=\"wp-image-123\" srcset=\"https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/QQ_1775471001741-1024x682.png 1024w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/QQ_1775471001741-300x200.png 300w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/QQ_1775471001741-768x512.png 768w, https:\/\/geocommunity.vip\/wp-content\/uploads\/2026\/04\/QQ_1775471001741.png 1186w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u79fb\u52a8\u8ddd\u79bb \uff081\uff09\u9898\u76ee\u63cf\u8ff0 \u5c0f\u660e\u521d\u59cb\u5728\u4e8c\u7ef4\u5e73\u9762\u7684 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":13,"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geocommunity.vip\/index.php\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}