{"id":54,"date":"2026-04-30T15:02:49","date_gmt":"2026-04-30T07:02:49","guid":{"rendered":"http:\/\/49.232.244.149\/?p=54"},"modified":"2026-04-30T15:15:59","modified_gmt":"2026-04-30T07:15:59","slug":"%e7%ae%97%e6%b3%95%e6%80%9d%e6%83%b3","status":"publish","type":"post","link":"https:\/\/www.everfades.cn\/index.php\/2026\/04\/30\/%e7%ae%97%e6%b3%95%e6%80%9d%e6%83%b3\/","title":{"rendered":"\u7b97\u6cd5\u601d\u60f3"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">\u2014\u2014by Everfades<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\uff08\u26a0\ufe0f\u5fc5\u8bfb\uff09\u672c\u7b14\u8bb0\u4e3b\u8981\u9488\u5bf9\u4e8e\u8f83\u4e3a\u6838\u5fc3\u7684\u516d\u5927\u7b97\u6cd5(\u4e3b\u89c2\u5411) <strong>\u679a\u4e3e\u3001\u8d2a\u5fc3\u3001\u5206\u6cbb\u3001\u56de\u6eaf\u3001\u641c\u7d22\u3001dp(\u52a8\u6001\u89c4\u5212)<\/strong> \u8fdb\u884c\u8bb0\u5f55\uff0c\u4e3b\u8981\u9762\u5411\u60f3\u8981\u53c2\u52a0\u7b97\u6cd5\u7ade\u8d5b\uff0c\u5177\u6709\u4e00\u5b9a\u7f16\u7a0b\u57fa\u7840\uff0c\u5e0c\u671b\u63d0\u5347\u7b97\u6cd5\u80fd\u529b\u7684\u540c\u5b66\uff0c\u8fd9\u91cc\u4f1a\u901a\u8fc7\u7b97\u6cd5\u8f85\u4ee5\u7ade\u8d5b\u771f\u9898\u8fdb\u884c\u8bb2\u89e3\u3002\u867d\u7136\u7b97\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u4f46\u662f\u57fa\u672c\u6240\u6709\u7684\u5176\u4ed6\u7b97\u6cd5\uff0c\u90fd\u662f\u53ef\u4ee5\u4ece\u4e0a\u8ff0\u7684\u516d\u5927\u7b97\u6cd5\u4e2d\u884d\u751f\u51fa\u6765\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9274\u4e8e\u7b14\u8005\u6c34\u5e73\u6709\u9650\uff0c\u90e8\u5206\u793a\u4f8b\u4ee5\u53ca\u4ee3\u7801\u53ef\u80fd\u5b58\u5728\u4e0d\u89c4\u8303\u7684\u4e66\u5199\uff0c\u751a\u81f3\u5b58\u5728\u7eb0\u6f0f\uff0c\u4e8e\u6b64\u8fd8\u671b\u89c1\u8c05\uff0c\u5982\u679c\u60a8\u6709\u5b9d\u8d35\u7684\u610f\u89c1\u6216\u5efa\u8bae\uff0c\u8bf7\u53d1\u90ae\u4ef6\u81f3:<a href=\"mailto:everfades1218@gmail.com\">everfades1218@gmail.com<\/a>\u6216<a href=\"mailto:everfades@foxmail.com\">everfades@foxmail.com<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e0c\u671b\u5927\u5bb6\u80fd\u4ece\u8fd9\u7bc7\u7b14\u8bb0\u4e2d\u53d6\u5f97\u4e00\u4e9b\u6536\u83b7\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff08\u26a0\u5728\u4f7f\u7528Typora\u9605\u8bfb\u524d\uff0c\u8bf7\u5c06\u6587\u4ef6\u2192\u504f\u597d\u8bbe\u7f6e\u2192Markdown\u2192\u5185\u8054\u516c\u5f0f \u52fe\u9009\u4e0a\uff0c\u4ee5\u514d\u663e\u793a\u51fa\u9519\uff01\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Part 1\uff1a\u679a\u4e3e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd5\u679a\u4e3e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8bb8\u591a\u6559\u7a0b\u4e2d\u4e2d\uff0c\u679a\u4e3e\u7b97\u6cd5\u7ecf\u5e38\u4f1a\u548c\u904d\u5386\uff0c\u66b4\u529b\uff0c\u751a\u81f3brute force\u7b97\u6cd5\u76f8\u6df7\u6dc6\uff0c\u5728\u63a5\u4e0b\u6765\u7684\u7b14\u8bb0\u4e2d\uff0c\u4f1a\u8be6\u7ec6\u7684\u5bf9\u679a\u4e3e\u7b97\u6cd5\u8fdb\u884c\u5256\u6790\uff0c\u63ed\u793a\u679a\u4e3e\u7b97\u6cd5\u7684\u6838\u5fc3\u6240\u5728\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u6211\u4eec\u4e0d\u59a8\u5bf9\u679a\u4e3e\u7b97\u6cd5\u4e0b\u4e2a\u5b9a\u4e49<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u679a\u4e3e\u7b97\u6cd5\u2193<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u67d0\u4e2a\u5305\u542b\u53ef\u80fd\u7684\u89e3\u7684<strong>\u96c6\u5408<\/strong>\u4e2d\uff0c\u6309\u67d0\u4e2a<strong>\u987a\u5e8f<\/strong>\u4f9d\u6b21\u68c0\u9a8c\u5143\u7d20\uff0c\u5e76\u7528\u9898\u76ee\u6240\u7ed9\u7684<strong>\u7ea6\u675f\u6761\u4ef6<\/strong>\u8fdb\u884c<strong>\u6821\u9a8c\u6216\u8ba1\u7b97<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e48\u8bf4\u53ef\u80fd\u6709\u70b9\u62bd\u8c61\uff0c\u6211\u4eec\u53ef\u4ee5\u4e3e\u4e2a\u4f8b\u5b50\u6765\u8bf4\u660e\u4e00\u4e0b\uff1a<strong>\u7ed9\u5b9a\u4e00\u4e2a\u6570\u7ec4\uff0c\u5224\u65ad\u662f\u5426\u5b58\u5728\u5947\u6570<\/strong>\uff0c\u90a3\u4e48\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<strong>\u96c6\u5408\u5c31\u662f\u7ed9\u5b9a\u7684\u6570\u7ec4<\/strong>\uff0c<strong>\u987a\u5e8f\u53ef\u4ee5\u662f\u6b63\u5411\u6216\u8005\u53cd\u5411\u90fd\u884c<\/strong>\uff0c<strong>\u6761\u4ef6\u5c31\u662f\u5143\u7d20\u662f\u5426\u4e3a\u5947\u6570<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u8fd9\u79cd<strong>\u662f\u5426\u5b58\u5728<\/strong>\u7684\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u79f0\u5176\u4e3a <strong>any of \u679a\u4e3e<\/strong>\uff0c\u6216\u8005 <strong>find if \u679a\u4e3e<\/strong>\uff0c\u76ee\u7684\u5728\u4e8e\u627e\u5230\u4e00\u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u5143\u7d20\u3002\u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u4ee5\u53d8\u5f62\u4e00\u4e0b\uff0c\u63a8\u5e7f\u51fa <strong>all of \u679a\u4e3e<\/strong>\uff0c <strong>none of \u679a\u4e3e<\/strong>\uff0c\u5728\u672c\u4f8b\u5b50\u4e2d\uff0c\u5373\u6240\u6709\u5143\u7d20\u90fd\u662f\u5947\u6570( all of )\uff0c\u6216\u6240\u6709\u5143\u7d20\u90fd\u4e0d\u662f\u5947\u6570( none of )\u3002\u5bf9\u4e8e\u8fd9\u4e09\u79cd\u679a\u4e3e\u6765\u8bf4\uff0c\u6734\u7d20\u7684\u5199\u6cd5\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a flag \u6765\u6807\u6ce8\u662f\u5426\u7b26\u5408\u9898\u610f\uff0c\u8fd9\u91cc\u5c31\u4e0d\u8fc7\u591a\u5c55\u5f00\u4e86\u3002\u6211\u4eec\u66f4\u591a\u4f1a\u4f7f\u7528STL\u5e93\u4e2d\u7684\u51fd\u6570\uff0c\u6bd4\u5982 <strong>any_of \uff0call_of \uff0cnone_of \uff0cfind_if \uff0c max_element \uff0c min_element \uff0c accumulate<\/strong> \u7b49\uff0c\u8fd9\u4e9b\u51fd\u6570\u90fd\u662f <strong>\u201c \u6cdb\u578b\u6a21\u677f\u51fd\u6570 \u201d<\/strong> \uff0c\u53ef\u4ee5\u7528\u4e8e\u4efb\u610f\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4ee5\u4e0a\u7b97\u662f\u679a\u4e3e\u6700\u57fa\u7840\u7684\u6a21\u578b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u518d\u6765\u770b\u4e2a\u8fdb\u9636\u4e00\u70b9\u7684\uff1a\u5728\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff0c\u5224\u65ad\u662f\u5426\u5b58\u5728\u5b50\u6570\u7ec4\uff1f<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u539f \u6570 \u7ec4\uff1a E V E R F A D E S<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u6807\u6570\u7ec4\uff1a E V A<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b50\u6570\u7ec4\u7684\u610f\u601d\u662f\uff0c\u4ece\u539f\u6570\u7ec4\u4e2d <strong>\u6309\u987a\u5e8f\u53d6\u51fa<\/strong> \u82e5\u5e72\u4e2a\u5143\u7d20\uff0c\u7ec4\u6210\u4e00\u4e2a\u65b0\u6570\u7ec4\u7b49\u4e8e\u76ee\u6807\u6570\u7ec4\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5957\u7528\u57fa\u7840\u7684\u6a21\u578b\uff0c\u76f8\u4fe1\u6709\u806a\u660e\u7684\u540c\u5b66\u5df2\u7ecf\u660e\u767d\u89e3\u6cd5\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u7528 <strong>find<\/strong> <strong>if<\/strong> \u7684\u6a21\u578b\u53bb\u5224\u65ad\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u67e5\u627e\u6210\u529f\u5219\u518d\u53bb\u5224\u65ad\u7b2c\u4e8c\u4e2a\u5143\u7d20\uff0c\u67e5\u627e\u6210\u529f\u5219\u518d\u53bb\u5224\u65ad\u7b2c\u4e09\u4e2a\u5143\u7d20&#8230;&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u8fd9\u91cc\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u5b58\u5728\u5b50\u6570\u7ec4\u7684\u7684\u5224\u65ad\u6761\u4ef6\uff0c\u6216\u8005\u8bf4\u8bbe\u7f6e\u7684 flag \u662f\u4ec0\u4e48\u5462\uff1f\u6211\u4eec\u76f4\u63a5\u6765\u770b\u6a21\u677f\u51fd\u6570<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">template &lt;typename T&gt;<br>bool subMatch(constT &amp;arr, const T &amp;target) {<br> &nbsp; &nbsp;size_t idx = 0;<br> &nbsp; &nbsp;for (auto &amp;elem : arr) {<br> &nbsp; &nbsp; &nbsp; &nbsp;if (elem == target[idx]) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (++idx ==target.size()) return true;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;return false;<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u8fd9\u4e2a\u51fd\u6570\u6a21\u677f\u4e2d\uff0c\u6211\u4eec\u4e0d\u96be\u770b\u51fa\uff0c\u5728\u904d\u5386 arr \u4e2d\u7684\u5143\u7d20\u65f6\uff0c\u6bcf\u5f53 elem ==target[idx] \u7684\u8fd4\u56de\u503c\u4e3a true\uff0cidx\u7684\u503c\u90fd\u4f1a +1 \uff0c\u76f4\u5230 idx \u7684\u503c\u4e0e target.size \u76f8\u7b49\uff0c\u5373\u5b50\u6570\u7ec4\u7684\u5927\u5c0f\u4e0e\u6211\u4eec\u7684\u76ee\u6807\u6570\u7ec4\u7684\u5927\u5c0f\u76f8\u7b49\u65f6\uff0c\u518d return true \uff0c\u4ee3\u8868\u627e\u5230\u4e86\u8fd9\u6837\u4e00\u4e2a\u5b50\u6570\u7ec4\uff0c\u5426\u5219\u8fd4\u56de false\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u518d\u6765\u8bf4\u5bf9\u4e8e\u679a\u4e3e\u7684\u4f18\u5316\uff0c\u6bd4\u5982\u56de\u6587\u4e32\u7684\u679a\u4e3e <del>( \u5173\u4e8e\u56de\u6587\u4e32\uff0c\u6709\u4e00\u4e2a\u7ecf\u5178\u7684\u7b11\u8bdd\uff0c(()) \u4e0d\u662f\u56de\u6587\u4e32\uff0c())( \u624d\u662f )<\/del><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int n = str.size();<br>for(int i = 0; i &lt; n; i++){<br> &nbsp; &nbsp;if(str[i] != str[n - i - 1]){<br>        return false;<br> &nbsp;  }<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u5b9a\u4e49\uff0c\u56de\u6587\u4e32\u7684\u6bcf\u4e2a\u5b57\u7b26\u5e94\u8be5\u548c\u5b83\u5bf9\u79f0\u4f4d\u7f6e\u7684\u5b57\u7b26\u76f8\u540c\uff0c\u56e0\u6b64\u6211\u4eec\u53ea\u9700\u8981\u679a\u4e3e\u524d\u4e00\u534a\u5c31\u53ef\u4ee5\u4e86\uff0c\u56e0\u4e3a\u540e\u4e00\u534a\u7684\u7ed3\u679c\u548c\u524d\u4e00\u534a\u4e00\u5b9a\u662f\u76f8\u540c\u7684<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int n = str.size();<br>for(int i = 0; i &lt; n \/ 2; i++){<br> &nbsp; &nbsp;if(str[i] != str[n - i - 1]){<br>        return false;<br> &nbsp;  }<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\u518d\u6765\u8bf4\u4e00\u4e2a\u5e38\u89c1\u7684\u5199\u6cd5\u2014\u2014<strong>\u6309\u4f4d\u679a\u4e3e<\/strong>\uff1a\u679a\u4e3e\u4e00\u4e2a\u6574\u6570\u7684\u6bcf\u4e00\u4f4d\uff0c\u7136\u540e\u8fdb\u884c\u9898\u76ee\u8981\u6c42\u7684\u5224\u65ad\u3002<strong>\uff08 &lt;\u2014 \u8fd9\u4e2a\u7528\u5230\u7684\u6bd4\u8f83\u591a \uff09<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for( ; x; x \/= base){   \/\/base \u4ee3\u8868\u8fdb\u5236\u6570<br>    int digit = x % base;<br>    \/\/do something<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6211\u4eec\u5c06\u679a\u4e3e\u51fa\u7684\u6bcf\u4e00\u4f4d\u5b58\u50a8\u5230\u6570\u7ec4\u4e2d\uff0c\u90a3\u5c31\u662f\u5c06\u6574\u6570\u8f6c\u5316\u6210\u5176\u4ed6\u8fdb\u5236<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vector&lt;int&gt; toDigits(int x, int base) {<br>    vector&lt;int&gt; digits;<br>    for( ; x; x \/= base){<br>        int digit = x % base;<br>        digit.push_back(digit); \/\/\u5728\u961f\u5217\u5c3e\u90e8\u63d2\u5165\uff0c\u800c\u4e0d\u662f\u50cf\u6570\u7ec4\u4e00\u6837\u5728\u5934\u90e8\u63d2\u5165\uff0c\u53ef\u4ee5\u5c11\u4e00\u6b65\u7ffb\u8f6c<br>    }<br>    return digits;<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u518d\u901a\u8fc7\u53e6\u4e00\u4e2a\u51fd\u6570\uff0c\u6211\u4eec\u8fd8\u80fd\u5c06\u6570\u7ec4\u8fd8\u539f\u56de\u539f\u6765\u7684\u6574\u6570<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int toDigit(vector&lt;int&gt; &amp;digits, int base) {<br>    int x = 0;<br>    for(int i = digits.size() - 1; i &gt;= 0; i--) {<br>        x = x * base +digits[i];    <br>    }<br>    return x;<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u6211\u4eec\u5e94\u8be5\u4e3a\u679a\u4e3e\u7b97\u6cd5\u8ba8\u4e2a\u516c\u9053\uff0c\u5b83\u5e76\u4e0d\u7b49\u4ef7\u4e8e\u66b4\u529b\u7b97\u6cd5\uff0c\u56e0\u4e3a\u66b4\u529b\u8fd9\u4e2a\u8bcd\u662f\u76f8\u5bf9\u7684\uff0c\u6709\u4e9b\u9898\u5b83\u7684\u6b63\u786e\u89e3\u6cd5\u5c31\u662f\u679a\u4e3e\uff1b\u5b83\u4e5f\u4e0d\u7b49\u4ef7\u4e8e\u904d\u5386\u7b97\u6cd5\uff0c\u56e0\u4e3a\u904d\u5386\u7684\u610f\u601d\u662f\u6309\u67d0\u4e2a\u987a\u5e8f\u8bbf\u95ee\u6570\u636e\u7ed3\u6784\u4e2d\u7684\u6240\u6709\u5143\u7d20\uff0c\u800c\u679a\u4e3e\u7b97\u6cd5\u663e\u7136\u66f4\u4e3a\u6cdb\u5316\uff0c\u5b83\u53ef\u4ee5\u5bf9\u4efb\u610f\u96c6\u5408\u8fdb\u884c\u679a\u4e3e\u3002\u53e6\u5916\uff0c\u540e\u9762\u7684\u56de\u6eaf\u7b97\u6cd5\u672c\u8d28\u4e0a\u4e5f\u662f\u4e00\u79cd\u679a\u4e3e\uff0c\u56e0\u4e3a\u56de\u6eaf\u7b97\u6cd5\u7684\u6838\u5fc3\u5176\u5b9e\u4e5f\u662f\u679a\u4e3e\u6240\u6709\u89e3\u7684\u96c6\u5408\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc710\u9053\u7ec3\u4e60\u9898\u6765\u5de9\u56fa\u4e00\u4e0b\u679a\u4e3e\u7b97\u6cd5\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd8a\u679a\u4e3e\u7ec3\u4e60<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Tips\uff1actrl + \u5355\u51fb\u84dd\u8272\u94fe\u63a5\u53ef\u76f4\u63a5\u8df3\u8f6c<\/em>\u81f3\u9898\u76ee<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/P10424\">-1.luogu P10424[\u84dd\u6865\u676f 2024 \u7701 B] \u597d\u6570\ud83d\udc4d<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u96be\u770b\u51fa\uff0c\u5728\u672c\u9898\u4e2d\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5bf91~N\u4e2d\u7684\u6bcf\u4e00\u4e2a\u6570\u5b57\u7684\u6bcf\u4e00\u4f4d\u8fdb\u884c\u6309\u4f4d\u679a\u4e3e\u5373\u53ef\uff0c\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e2a\u597d\u6570\u4e2a\u6570\u7684\u8ba1\u6570\u5668 goodCount\uff0c\u8bbe\u7f6e\u4e00\u4e2a bool \u7c7b\u578b\u7684 isGood\uff0c\u5982\u679c\u5728\u6309\u4f4d\u679a\u4e3e\u7684\u8fc7\u7a0b\u4e2d\u6709\u67d0\u4e00\u4f4d\u4e0d\u6ee1\u8db3\u6761\u4ef6\uff0c\u5219\u5c06 isGood \u8bbe\u7f6e\u4e3a false\uff0c\u5e76\u9000\u51fa\u540e\u7eed\u5faa\u73af\uff0c\u4e24\u4e2a\u5d4c\u5957\u5faa\u73af\u7ed3\u675f\u540e\uff0c\u6253\u5370 goodCount \u7684\u503c\uff0c\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>typedef long long ll;<br>int main(void) {<br> &nbsp; &nbsp;ll n;<br> &nbsp; &nbsp;cin &gt;&gt; n;<br> &nbsp; &nbsp;ll goodCount = 0; &nbsp; \/\/\u597d\u6570\u7684\u4e2a\u6570<br> &nbsp; &nbsp;bool isGood = true; \/\/flag<br> &nbsp; &nbsp;for(int i = 1; i &lt;= n; i++) {<br> &nbsp; &nbsp; &nbsp; &nbsp;isGood = true;<br> &nbsp; &nbsp; &nbsp; &nbsp;ll index = 1; &nbsp; \/\/\u7b2c\u4e00\u4f4d\u662f\u5947\u6570<br> &nbsp; &nbsp; &nbsp; &nbsp;ll x = i;<br> &nbsp; &nbsp; &nbsp; &nbsp;while(x) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ll digit = x % 10; &nbsp;\/\/\u7528digit\u63d0\u53d6\u51fa\u6700\u4f4e\u4f4d<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (index % 2 != digit % 2) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isGood = false;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index ++;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x \/= 10;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;if (isGood) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;goodCount++;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;cout &lt;&lt; goodCount &lt;&lt; endl;<br> &nbsp; &nbsp;return 0;<br>}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/1%E6%9E%9A%E4%B8%BEP10424%20%5B%E8%93%9D%E6%A1%A5%E6%9D%AF%202024%20%E7%9C%81%20B%5D%20%E5%A5%BD%E6%95%B0.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/1%E6%9E%9A%E4%B8%BEP10424%20%5B%E8%93%9D%E6%A1%A5%E6%9D%AF%202024%20%E7%9C%81%20B%5D%20%E5%A5%BD%E6%95%B0.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"1\u679a\u4e3eP10424 [\u84dd\u6865\u676f 2024 \u7701 B] \u597d\u6570\"\/><\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.lanqiao.cn\/problems\/3491\/learning\/\">-2.lanqiao[\u84dd\u6865\u676f 2023 \u7701 A]\u5e78\u8fd0\u6570\u2764<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u662f\u4e00\u9053\u7ed3\u679c\u586b\u7a7a\u9898\uff0c\u5728\u8bc4\u6d4b\u673a\u4e0a\uff0c\u6211\u4eec\u53ea\u9700\u8981 cout \u51fa\u9898\u76ee\u8981\u6c42\u7684\u7ed3\u679c\u5373\u53ef\uff0c\u8fd9\u5c31\u610f\u5473\u7740\u6211\u4eec\u53ef\u4ee5<strong>\u6682\u4e14\u5ffd\u7565\u8bc4\u6d4b\u673a\u9650\u5236\u7684\u65f6\u7a7a\u590d\u6742\u5ea6<\/strong>\uff0c\u53ea\u8981\u80fd\u6c42\u89e3\u51fa\u7b54\u6848\u5373\u53ef\u3002\u5bf9\u4e8e\u672c\u9898\u800c\u8a00\uff0c\u6211\u4eec\u53ef\u4ee5\u91c7\u7528\u6700\u6734\u7d20\u7684\u505a\u6cd5\uff0c\u76f4\u63a5\u4ece1\u679a\u4e3e\u52301e8\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u5e78\u8fd0\u6570\u8ba1\u6570\u5668 luckyCount \uff0c\u8bbe\u7f6e\u4e00\u4e2a digitCount \u7528\u4e8e\u8ba1\u7b97\u4f4d\u6570\uff0c\u5e76\u8bbe\u7f6e\u5de6\u53f3\u4e24\u8fb9\u6c42\u548c\u7684\u6570leftNum\uff0crightNum\uff0c\u4ee5\u53ca\u4f4d\u6570\u7684\u4e2d\u503chalf\uff0c\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>typedef long long ll;<br>int main(void){<br> &nbsp; &nbsp;ll luckyCount = 0;<br> &nbsp; &nbsp;for(ll i = 1; i &lt;= 100000000; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp;ll digitCount = [](ll x){       \/\/\u4f7f\u7528lambda \u8868\u8fbe\u5f0f<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ll cnt = 0;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for(; x; x \/= 10) cnt++;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return cnt;<br> &nbsp; &nbsp; &nbsp;  }(i);<br> &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp;if(digitCount &amp;1) continue;     \/\/digitCount &amp;1 \u7684\u610f\u601d\u662f\uff0c\u82e5 digitCount \u662f\u5947\u6570\uff0c\u5176\u4e8c\u8fdb\u5236\u7684\u4e2a\u4f4d\u4e00\u5b9a\u4e3a1\uff0c\u90a3\u4e48 &amp;1 \u7684\u7ed3\u679c\u4e3atrue<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;if([](ll x, ll digitCount){         \/\/\u4f7f\u7528lambda \u8868\u8fbe\u5f0f<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ll half = digitCount &gt;&gt; 1;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ll leftNum = 0,rightNum = 0;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for(ll i = 0; x; x \/= 10, i++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(i &lt; half) leftNum += x % 10;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else rightNum += x % 10;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return leftNum == rightNum;<br> &nbsp; &nbsp; &nbsp;  }(i,digitCount))luckyCount++;<br>  }<br> &nbsp;cout &lt;&lt; luckyCount &lt;&lt; endl;<br> &nbsp;return 0;<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5148\u5728\u81ea\u5df1\u7684\u8ba1\u7b97\u673a\u4e0a run \u4e00\u4e0b\u4ee3\u7801\uff0c\u907f\u514dTLE<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/2%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A53491%20%E5%B9%B8%E8%BF%90%E6%95%B0.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/2%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A53491%20%E5%B9%B8%E8%BF%90%E6%95%B0.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"2\u679a\u4e3e\u84dd\u68653491 \u5e78\u8fd0\u6570\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7684\u7ed3\u679c\u4e3a 4430091\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u8bc4\u6d4b\u673a\u4e0a\u6253\u5370\u7ed3\u679c\u5c31\u53ef\u4ee5\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>int main(void)<br>{ &nbsp; <br> &nbsp;cout &lt;&lt; 4430091 &lt;&lt; endl;<br> &nbsp;return 0;<br>}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/3%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A53491%20%E5%B9%B8%E8%BF%90%E6%95%B0.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/3%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A53491%20%E5%B9%B8%E8%BF%90%E6%95%B0.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"3\u679a\u4e3e\u84dd\u68653491 \u5e78\u8fd0\u6570\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f\u6ce8\u610f\uff1a\u672c\u9898\u6709\u4e00\u4e2a\u6bd4\u8f83\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u70b9\uff0c\u90a3\u5c31\u662f\u5728\u7b2c\u516d\u884c\u7684 for \u5faa\u73af\u4e2d\uff0c\u6709\u540c\u5b66\u53ef\u80fd\u4f1a\u5199\u6210<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for(ll i = 0; i &lt; 100000000; i++);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e4d\u4e00\u770b\u4f3c\u4e4e\u6ca1\u6709\u95ee\u9898\uff0c\u4e8c\u8005\u90fd\u662f\u5faa\u73af100000000\u6b21\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\uff0c\u5728 lambda \u8868\u8fbe\u5f0f\u4f20\u503c\u7684\u65f6\u5019\uff0ci = 0 \u4f1a\u88ab\u9519\u8bef\u7684\u4f20\u9012\u8fdb\u53bb\uff0c\u5b83\u4f1a\u987a\u5229\u901a\u8fc7 &amp;1 \u7684\u5224\u65ad\uff0c\u6700\u540e\u5bfc\u81f4\u8f93\u51fa\u7684 luckyCount \u6bd4\u6b63\u786e\u7b54\u6848\u591a\u4e00\uff0c\u9519\u8bef\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/4%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A53491%20%E5%B9%B8%E8%BF%90%E6%95%B0.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/4%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A53491%20%E5%B9%B8%E8%BF%90%E6%95%B0.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"4\u679a\u4e3e\u84dd\u68653491 \u5e78\u8fd0\u6570\"\/><\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.lanqiao.cn\/problems\/1443\/learning\/?page=1&amp;first_category_id=1&amp;problem_id=1443\">-3.lanqiao[\u84dd\u6865\u676f 2021 \u7701 B]\u5361\u7247\ud83c\udfb4<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u77e5\u9053\uff0c\u5c0f\u84dd0~9\u7684\u5361\u7247\u6bcf\u5f20\u90fd\u67092021\u5f20\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece 1 \u5f00\u59cb\u904d\u5386\uff0c\u5199\u4e00\u4e2a\u6b7b\u5faa\u73af\uff0c\u5bf9\u8fd9\u4e9b\u6570\u5b57\u7684\u6bcf\u4e00\u4f4d\u8fdb\u884c\u6309\u4f4d\u679a\u4e3e\uff0c\u5bf9\u679a\u4e3e\u5230\u7684\u6570\u5b57\uff0c\u5361\u7247\u6570\u91cf &#8211; 1\uff0c\u76f4\u5230\u67d0\u4e00\u4e2a\u6570\u5b57\u7684\u5361\u7247\u6570\u91cf\u4e3a 0 \uff0c\u4ee3\u8868\u65e0\u6cd5\u62fc\u6210\u8fd9\u4e2a\u6570\u5b57\uff0c\u90a3\u4e48\u6211\u4eec\u8f93\u51fa\u5b83\u7684\u524d\u4e00\u4f4d i &#8211; 1 \u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u7ed9\u51fa\u4e86\u4e00\u79cd\u6734\u7d20\u7684\u505a\u6cd5\uff0c\u5728 cards[digit] == 0 \u65f6\uff0c\u6211\u4eecbreak\u51fa\u5f53\u524d\u5faa\u73af\uff0c\u4f46\u6211\u4eec\u53ea\u80fd\u8df3\u51fa\u7b2c\u4e00\u5c42\uff0c\u800c\u65e0\u6cd5\u8df3\u51fa\u7b2c\u4e8c\u5c42\u5faa\u73af\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a flag \u5e76\u521d\u59cb\u5316\u4e3a false\uff0c\u5f53 cards[digit] == 0 \u65f6\uff0c\u6211\u4eec\u4ee4 flag = true \uff0c\u5728\u5916\u5c42\u5faa\u73af\u4e2d\u5224\u65ad\uff0c\u5f53 flag == true \u7684\u65f6\u5019\uff0c\u8f93\u51fa i &#8211; 1 \u5e76\u518dbreak\u4e00\u6b21\uff0c\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86\u8df3\u51fa\u5faa\u73af\uff0c\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>int main(void){<br>    vector&lt;int&gt; cards(10,2021);<br>    for(int i = 1; ; i++){<br>        bool flag = false; <br>        for(int j = i; j; j \/= 10){<br>            int digit = j % 10;<br>            if(cards[digit] == 0){<br>                flag = true;<br>                break;<br>            }<br>            cards[digit]--;<br>        }<br>        if(flag == true){<br>            cout &lt;&lt; i - 1 &lt;&lt; endl;<br>            break;<br>        }<br>    }<br>    return 0;<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u91c7\u7528\u7b2c\u4e8c\u9898\u7684 lambda\uff0c\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>int main(void){<br> &nbsp; &nbsp;vector&lt;int&gt; cards(10,2021);<br> &nbsp; &nbsp;for(int i = 1; ; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp;if([&amp;](){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int d = i; d; d \/= 10){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int digit = d % 10;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (cards[digit] == 0) return true;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cards[digit]--; &nbsp; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;<br> &nbsp; &nbsp; &nbsp;  }()){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cout &lt;&lt; i - 1 &lt;&lt; endl;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br>}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/5%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A51065%E5%8D%A1%E7%89%87.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/5%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A51065%E5%8D%A1%E7%89%87.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"5\u679a\u4e3e\u84dd\u68651065\u5361\u7247\"\/><\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.lanqiao.cn\/problems\/19732\/learning\/?page=1&amp;first_category_id=1&amp;problem_id=19732\">-4.lanqiao[\u84dd\u6865\u676f 2024 \u7701 B] \u5c0f\u7403\u53cd\u5f39 \u26bd<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u9898\u76ee\u6307\u5f15\u7684\u601d\u8def\uff0c\u6211\u4eec\u9700\u8981\u8ba1\u7b97\u5c0f\u7403\u53cd\u5c04\u7684\u70b9\u5e76\u53cd\u5c04\u901f\u5ea6\uff0c\u8fd9\u6837\u7684\u51e0\u4f55\u8fd0\u7b97\u6781\u5176\u590d\u6742\uff0c\u6d89\u53ca\u7684\u6761\u4ef6\u4e5f\u5341\u5206\u7684\u591a\uff0c\u6211\u4eec\u4e0d\u59a8\u8f6c\u6362\u4e00\u4e0b\u601d\u8def\ud83e\udd13\ud83d\udc46\uff0c\u6211\u4eec\u73b0\u5728\u9700\u8981\u8ba1\u7b97\u7684\u662f\u5c0f\u7403\u662f\u5426\u80fd\u5426\u5230\u8fbe \u201c\u539f\u70b9\u201d \uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u539f\u957f\u65b9\u5f62\u5411\u53f3\u7ffb\u8f6c\u590d\u5236\u4e00\u4efd\uff0c\u518d\u5411\u4e0b\u7ffb\u8f6c\u590d\u5236\u4e00\u4efd\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u83b7\u5f97\u4e86\u4e00\u4e2a\u957f\u4e3a 343720 * 2 \uff0c\u5bbd\u4e3a 233333 * 2 \u7684\u957f\u65b9\u5f62\uff0c\u5b83\u7684\u56db\u4e2a\u89d2\u90fd\u662f \u201c\u539f\u70b9\u201d \uff0c\u90a3\u4e48\u6211\u4eec\u4fbf\u53ef\u4ee5\u8ba9\u5c0f\u7403\u4e00\u76f4\u6cbf\u7740\u539f\u8def\u7ebf\u524d\u8fdb\uff0c\u5e76\u4e14\u4e0d\u65ad\u7684\u590d\u5236\u8fd9\u4e2a\u957f\u65b9\u5f62\uff0c\u76f4\u5230\u5c0f\u7403\u521a\u597d\u5230\u8fbe\u7b2c\u4e00\u4e2a\u539f\u70b9\u4e3a\u6b62\uff0c\u6700\u540e\u7528\u52fe\u80a1\u5b9a\u7406\u8ba1\u7b97\u51fa\u5c0f\u7403\u8fd0\u52a8\u7684\u8ddd\u79bb\u5373\u53ef\uff0c\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>typedef long long ll;<br>int main(void){<br> &nbsp; &nbsp;ll dx = 15,dy = 17;<br> &nbsp; &nbsp;ll width = 343720 * 2, hight = 233333 * 2;      \/\/\u65b0\u957f\u65b9\u5f62\u7684\u957f\uff0c\u5bbd\uff0c\u4e3a\u539f\u957f\u5bbd\u7684\u4e8c\u500d<br> &nbsp; &nbsp;for(int t = 1; ; t++){      \/\/\u65e0\u9650\u5faa\u73af      <br>\/\/\u8fd9\u91cct * dx % width == 0 \u4ee3\u8868\u5c0f\u7403\u89e6\u5230\u5e95\u8fb9\uff0ct * dy % hight == 0 \u4ee3\u8868\u5c0f\u7403\u89e6\u5230\u53f3\u8fb9\uff0c\u540c\u65f6\u6ee1\u8db3\u5219\u4ee3\u8868\u5230\u8fbe\u201c\u539f\u70b9\u201d<br> &nbsp; &nbsp; &nbsp; &nbsp;if(t * dx % width == 0 &amp;&amp; t * dy % hight == 0){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ &lt;&lt; fixed &lt;&lt;setprecision(2) \u4ee3\u8868\u8bbe\u7f6e\u8f93\u51fa\u5230\u5c0f\u6570\u70b9\u540e\u4e24\u4f4d\uff0chypot \u4e3a\u52fe\u80a1\u5b9a\u7406\u8ba1\u7b97\u51fd\u6570<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cout &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; hypot(t * dx, t * dy) &lt;&lt; endl; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;return 0;<br>}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/6%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A519732%E5%B0%8F%E7%90%83%E5%8F%8D%E5%BC%B9.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/6%E6%9E%9A%E4%B8%BE%E8%93%9D%E6%A1%A519732%E5%B0%8F%E7%90%83%E5%8F%8D%E5%BC%B9.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"6\u679a\u4e3e\u84dd\u686519732\u5c0f\u7403\u53cd\u5f39\"\/><\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/P1149\">-5.luogu P1149 [NOIP 2008 \u63d0\u9ad8\u7ec4] \u706b\u67f4\u68d2\u7b49\u5f0f\ud83d\udd25<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">NOIP 2008\u5e74\u7684\u63d0\u9ad8\u7ec4 ( \u8fd9\u771f\u662f\u63d0\u9ad8\u7ec4\u5417\uff1f)\uff0c\u8fd9\u9053\u9898\u7684\u8981\u6c42\u662f\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u7ed9\u5b9a\u7684 n \uff0c\u6c42\u80fd\u62fc\u6210\u7b26\u5408\u9898\u610f\u7684\u7b49\u5f0f\u7684\u6570\u91cf\uff0c\u90a3\u4e48\u6211\u4eec\u4e0d\u96be\u60f3\u5230\u679a\u4e3e\u7b97\u6cd5\u3002\u9898\u5e72\u8fd8\u6709\uff0cA + B = C \u548c B + A = C \u89c6\u4e3a\u4e0d\u540c\u7684\u7b49\u5f0f\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u5bf9 A \u548c B \u90fd\u8fdb\u884c\u679a\u4e3e\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u7528\u4e8e\u8ba1\u7b97\u6d88\u8017\u4e86\u591a\u5c11\u706b\u67f4\u68d2\u7684\u51fd\u6570 cnt() \uff0c\u6700\u540e\u5224\u65ad\u4e00\u4e0bif(cnt(A) + cnt(B) + cnt(C) + 4 == n) \u5373\u53ef\uff0c\u5982\u679c\u76f8\u7b49\u5219\u4ee4\u8ba1\u6570\u5668 ans++ \uff0c\u601d\u8def\u975e\u5e38\u6e05\u6670\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u662f\u672c\u9898\u7684\u5173\u952e\u70b9\u5728\u4e8e\u5982\u4f55\u786e\u5b9a\u679a\u4e3e\u7684\u8303\u56f4\uff0c\u89c2\u5bdf\u8f93\u5165\u683c\u5f0f\uff0c\u53d1\u73b0\u9898\u76ee\u6240\u7ed9\u51fa\u7684 n \u7684\u8303\u56f4\u4e3a 1 \u2264 n \u2264 24\uff0c\u5e76\u4e14\u6211\u4eec\u8fd8\u9700\u8981 4 \u6839\u706b\u67f4\u68cd\u6784\u6210 &#8220;+&#8221; \u548c &#8220;=&#8221; \uff0c\u6240\u4ee5\u5b9e\u9645\u6211\u4eec\u80fd\u7528\u6765\u6784\u6210\u6570\u5b57\u7684\u53ea\u670920\u6839\u706b\u67f4\u68d2\uff0c\u90a3\u4e48\u6211\u4eec\u4fbf\u9700\u8981\u627e\u5230\u4e00\u4e2a\u6700\u5927\u7684\u6570\u5b57\u4f5c\u4e3a\u679a\u4e3e\u4e0a\u754c\u3002\u9996\u5148\u6211\u4eec\u8981\u660e\u786e\u4e00\u70b9\uff0c\u90a3\u5c31\u662f\u6211\u4eec\u7684\u706b\u67f4\u68d2\uff0c\u4f7f\u7528\u7684\u4f18\u5148\u7ea7\u6c38\u8fdc\u662f\u589e\u52a0 &#8220;\u6570\u4f4d&#8221;\uff0c\u800c\u4e0d\u662f\u589e\u5927 &#8220;\u6570\u5b57&#8221;\uff0c\u5047\u8bbe\u6211\u4eec\u73b0\u5728\u6709 6 \u6839\u706b\u67f4\u68d2\u7528\u6765\u6784\u6210\u4e00\u4e2a\u6570\u5b57\uff0c\u90a3\u4e48\u663e\u7136 &#8220;111&#8221; \u5fc5\u7136\u662f\u6700\u5927\u7684\u89e3\uff0c\u6ca1\u6709\u5176\u4ed6\u60c5\u51b5\uff08\u5927\u5bb6\u53ef\u4ee5\u8bd5\u4e00\u4e0b\uff09\u3002\u4f46\u5047\u8bbe\u6211\u4eec\u6709 7 \u6839\u706b\u67f4\u68d2\uff0c\u6784\u6210 &#8220;111&#8221; \u4e4b\u540e\uff0c\u4f59\u4e0b\u7684\u4e00\u6839\u6ca1\u529e\u6cd5\u518d\u589e\u52a0 &#8220;\u6570\u4f4d&#8221; \uff0c\u90a3\u4e48\u6211\u4eec\u518d\u8003\u8651\u589e\u52a0 &#8221; \u6570\u5b57 &#8221; \uff0c\u6700\u5927\u6570\u4e3a &#8220;711&#8221;\uff0c\u8fd9\u91cc\u4e0d\u591a\u8bc1\u660e\u3002\u5bf9\u4e8e n == 24 \u800c\u8a00\uff0c\u6211\u4eec\u80fd\u627e\u5230\u7684A(B)\u6700\u5927\u7684\u7b49\u5f0f\u4e3a &#8221; 711 + 1 = 712&#8243;\uff08\u6d88\u801723\u6839\u706b\u67f4\u68d2\uff09\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u518d\u7a0d\u5fae\u589e\u52a0\u679a\u4e3e\u4e0a\u754c\u52301000\uff0c\u8fd9\u6837\u662f\u6bd4\u8f83\u5b89\u5168\u7684\uff0c\u4ee3\u7801\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>int main(void){<br> &nbsp; &nbsp;int n;<br> &nbsp; &nbsp;cin &gt;&gt; n;<br>    int digits[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};  \/\/\u6bcf\u4e2a\u6570\u5b57\u6240\u9700\u8981\u7684\u706b\u67f4\u68d2\u6570<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;auto cnt = [&amp;](int x){      \/\/\u8ba1\u7b97\u6570\u5b57\u6240\u9700\u8981\u7684\u706b\u67f4\u68d2\u51fd\u6570<br> &nbsp; &nbsp; &nbsp; &nbsp;if(x == 0)return digits[0];<br> &nbsp; &nbsp; &nbsp; &nbsp;int num = 0;<br> &nbsp; &nbsp; &nbsp; &nbsp;for(; x; x \/= 10){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;num += digits[x%10];<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return num;<br> &nbsp;  };<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;int ans = 0;<br> &nbsp; &nbsp;for(int a = 0; a &lt;= 1000; a++){         \/\/\u679a\u4e3e<br> &nbsp; &nbsp; &nbsp; &nbsp;for (int b = 0; b &lt;= 1000; b++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int c = a + b;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (cnt(a) + cnt(b) + cnt(c) + 4 == n) ans++;       \/\/\u7b26\u5408\u6761\u4ef6\u5219ans++<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;cout &lt;&lt; ans;<br> &nbsp; &nbsp;return 0; <br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5047\u8bbe\u679a\u4e3e\u8303\u56f4\u6ca1\u6709\u5224\u65ad\u597d\uff0c\u5bfc\u81f4TLE\u4e86\uff0c\u90a3\u5e94\u8be5\u600e\u4e48\u529e\u5462\ud83e\udd14\uff1f n \u7684\u8303\u56f4\u4e3a 1 \u2264 n \u2264 24 \uff0c\u8f93\u5165\u7684\u6570\u636e\u8303\u56f4\u6bd4\u8f83\u5c0f\uff0c\u90a3\u6211\u4eec\u5c31\u53ef\u4ee5\u5c06\u6240\u6709\u7684\u7b54\u6848\u5728\u81ea\u5df1\u7684\u8ba1\u7b97\u673a\u4e2d\u8fd0\u884c\u51fa\u6765\uff0c\u518d\u5c06\u7b54\u6848\u4fdd\u5b58\u5230\u4e00\u4e2a answer \u6570\u7ec4\u91cc\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684 n \u8f93\u5165\uff0c\u6211\u4eec\u76f4\u63a5\u8fd4\u56de answer[n] \u5373\u53ef\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684 n \uff0c\u7b54\u6848 run \u51fa\u6765\u7684\u8fc7\u7a0b\u5c31\u4e0d\u591a\u8d58\u8ff0\uff0c\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>int main(void){<br> &nbsp; &nbsp;int n;<br> &nbsp; &nbsp;cin &gt;&gt; n;<br> &nbsp; &nbsp;int answer[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 8, 9, 6, 9, 29, 39, 38, 65, 88, 128};<br> &nbsp; &nbsp;cout &lt;&lt; answer[n] &lt;&lt; endl;<br> &nbsp; &nbsp;return 0;<br>}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/7%E6%9E%9A%E4%B8%BEP1149NOIP%202008%E6%8F%90%E9%AB%98%E7%BB%84.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/7%E6%9E%9A%E4%B8%BEP1149NOIP%202008%E6%8F%90%E9%AB%98%E7%BB%84.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"7\u679a\u4e3eP1149NOIP 2008\u63d0\u9ad8\u7ec4\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u79cd\u7b54\u6848\u5747\u987a\u5229AC\uff0c\u6211\u4eec\u521a\u624d\u6240\u63d0\u5230\u7684\u7b2c\u4e8c\u79cd\u5c06\u7b54\u6848\u4fdd\u5b58\u5230\u6570\u7ec4\u4e2d\u7684\u65b9\u6cd5\uff0c\u5c31\u53eb \u201c\u6253\u8868\u201d\ud83e\udd13\ud83d\udc46\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4e00\u822c\u9002\u5408\u8f93\u5165\u6570\u636e\u8303\u56f4\u5c0f\uff0c\u4e14\u6bd4\u8f83\u5bb9\u6613 TLE \u7684\u9898\u76ee\u4e2d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd5\u524d\u7f00\u548c-prefix<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ed9\u4f60\u4e00\u6bb5\u6570\u7ec4\uff0c\u8ba9\u4f60\u6c42\u4e00\u6bb5\u533a\u95f4 L \u5230 R \u7684\u548c\uff0c\u6211\u4eec\u53ea\u9700\u8981\u679a\u4e3e\u4ece L \u5230 R \u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int sum = 0;<br>for(int i = L; i &lt;= R; i++){<br>    sum += arr[i];<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u5982\u679c\u6709 M \u6b21\u67e5\u8be2\u5462\ud83e\udd14\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int sum = 0;<br>while(M--){<br>    for(int i = L; i &lt;= R; i++){<br>        sum += arr[i];<br>    }<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u6b21\u90fd\u67e5\u8be2\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u5c31\u53d8\u6210\u4e86\uff0c\u67e5\u8be2\u6b21\u6570 \u00d7 \u533a\u95f4\u957f\u5ea6\uff0c\u5373O(MN)\uff0c\u8fd9\u663e\u7136\u6548\u7387\u592a\u4f4e\u4e86\u274c\uff0c\u4e3a\u4e86\u66f4\u52a0\u9ad8\u6548\u7684\u5904\u7406\u67e5\u8be2\u8bf7\u6c42\uff0c\u6211\u4eec\u4fbf\u4f1a\u91c7\u7528\u4e00\u79cd\u540d\u4e3a &#8221; \u524d\u7f00\u548c &#8221; \u7684\u7b97\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vector&lt;int&gt; prefix(n);<br>for(int i= 0; i &lt; n; i++){<br>    if(i) &nbsp;prefix[i] = prefix[i - 1];<br>    prefix[i] += arr[i];<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4e5f\u53ef\u4ee5\u7528C++98\u4e2d\u5f15\u5165\u7684\u4e00\u4e2aSTL\u51fd\u6570 : partial_sum()\uff0c\u5b83\u4f4d\u4e8e numeric\u5e93\u4e2d\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u548c\u4e0a\u9762\u662f\u5b8c\u5168\u7b49\u4ef7\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vector&lt;int&gt; prefix(n);<br>partial_sum(arr.begin(), arr.end(), prefix.begin());\/\/\u53c2\u6570\u5206\u522b\u4e3a\uff1a\u8d77\u59cb\uff0c\u7ec8\u6b62\uff0c\u76ee\u6807\u4f4d\u7f6e<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5047\u5982\u6211\u4eec\u8981\u8fdb\u884c\u53cd\u5411\u904d\u5386\uff0c\u90a3\u4e48\u53ea\u9700\u8981\u5199\u6210 partial_sum(arr.rbegin(), arr.rend(), prefix.rbegin()); \uff0c\u7b80\u5355\u4fee\u6539\u4e00\u4e0b\u8fed\u4ee3\u5668\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u8bf4\u67e5\u8be2\uff0c\u6bd4\u5982\u8981\u67e5\u8be2 L \u5230 R \u7684\u533a\u95f4\u548c\uff0csum(L, R) = prefix[ R ] &#8211; prefix[ L &#8211; 1 ]; \u5047\u8bbe L = 3\uff0cR = 6\uff0c\u90a3\u4e48prefix[ 3 ] = 1 + 2 + 3 , prefix[ 6 ] = 1 +2 + 3 + 4 + 5 + 6 , prefix[ 6 ] &#8211; prefix[ 2 ] = 3 + 4 + 5 + 6\u3002\u4f46\u5982\u679c L \u662f 0 \uff0c\u90a3\u4e48 L &#8211; 1\u5c31\u8d8a\u754c\u4e86\uff0c\u8fd9\u65f6\u6211\u4eec\u6709\u4e24\u79cd\u5904\u7406\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2460\uff1a\u7b2c\u4e00\u79cd\u662f\u5bf9 L == 0 \u7684\u60c5\u51b5\u8fdb\u884c\u7279\u5224\uff1aL ==0 \u65f6\uff0c\u76f4\u63a5\u8fd4\u56de prefix[ R ] \u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2461\uff1a\u7b2c\u4e8c\u79cd\u5219\u662f\u5728\u8ba1\u7b97 prefix \u65f6\uff0c\u4e0b\u6807\u4ece 1 \u5f00\u59cb\u8ba1\u6570\uff0c\u8fd9\u6837 L \u7684\u6700\u5c0f\u503c\u4e5f\u5c31\u662f 1 \uff0cL &#8211; 1 \u4e5f\u5c31\u4e0d\u4f1a\u8d8a\u754c\u4e86\u3002\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vector&lt;int&gt; arr(n + 1),prefix(n + 1);<br>for(int i = 1; i &lt;= n; i++){<br>    cin &gt;&gt; arr[i];<br>}<br>partial_sum(arr.begin(), arr.end(), prefix.begin());<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8303\u56f4\u5faa\u73af\uff0c\u4e24\u79cd\u5747\u53ef\uff0c\u770b\u4e2a\u4eba\u559c\u597d\u9009\u62e9\u5199\u6cd5\ud83d\udc4d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vector&lt;int&gt; arr(n)\uff0cprefix(n + 1);<br>for(auto &amp;x : arr) cin &gt;&gt; x;<br>partial_sum(arr.begin(), arr.end(), prefix.begin() + 1);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u6309\u7167\u8fd9\u4e2a\u601d\u8def\uff0c\u5c06\u524d\u7f00\u548c\u63a8\u5e7f\u5230\u524d\u7f00\u79ef\u548c\u524d\u7f00\u5f02\u6216\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u524d\u7f00\u79ef\uff1amul(L,R) = prefix(R) \/ prefix(L - 1);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uff08\u6ce8\uff1a\u5bf9\u4e8e int \u7c7b\u578b\u7684\u6570\u636e\uff0c2\u2076\u2074 \u5c31\u6ea2\u51fa\u4e86\uff0c\u56e0\u6b64\u6211\u4eec\u4e00\u822c\u4f1a\u5bf9\u524d\u7f00\u79ef\u7684\u7ed3\u679c\u8fdb\u884c\u53d6\u6a21\u8fd0\u7b97\uff0c\u4e00\u65e6\u53d6\u6a21\uff0c\u8fd8\u539f\u56de\u6765\u90a3\u5c31\u4e0d\u662f\u7b80\u5355\u7684\u9006\u8fd0\u7b97\u4e86\uff0c\u8fd9\u5c5e\u4e8e\u201c\u4e58\u6cd5\u9006\u5143\u201d\u7684\u8303\u7574\uff0c\u4f1a\u8fd0\u7528\u5230\u8d39\u9a6c\u5c0f\u5b9a\u7406\u548c\u5feb\u901f\u5e42\ud83d\ude28\uff0c\u5bf9\u4e8e\u7b97\u6cd5\u65b0\u624b\u6765\u8bf4\uff0c\u8fd9\u90e8\u5206\u6709\u4e00\u5b9a\u96be\u5ea6\uff0c\u5728\u6b64\u5c31\u4e0d\u8fdb\u884c\u5c55\u5f00\u4e86\uff0c\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u8bd5\u7740\u5c06\u8fd9\u51e0\u4e2a\u77e5\u8bc6\u70b9\u7ed3\u5408\u8d77\u6765\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u524d\u7f00\u5f02\u6216\uff1axor(L,R) = prefix(R) ^ prefix(R - 1);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f02\u6216\u7684\u8fd0\u7b97\u5982\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-preformatted\">True ^ False = True<br>\u200b<br>False ^ True = True<br>\u200b<br>False ^ False = False<br>\u200b<br>True ^ True = False<\/pre>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5373\u76f8\u5f02\u4e3a\u771f\uff0c\u76f8\u540c\u4e3a\u5047\uff0c\u5176\u9006\u8fd0\u7b97\u540c\u6837\u4e3a\u5f02\u6216\uff0c\u5c11\u4e86\u5f88\u591a\u9ebb\u70e6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u518d\u6765\u770b\u5f02\u6216\u8fd0\u7b97\u4e00\u4e2a\u6709\u8da3\u7684\u6027\u8d28\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u539f \u6570 \u7ec4\uff1a2 2 7 5 7 2 1 4 1 5<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2193 \u2193<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2193 \u2193<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u524d\u7f00\u5f02\u6216\u6570\u7ec4\uff1a2 0 <em><strong>7<\/strong><\/em> 2 5 <em><strong>7<\/strong><\/em> 6 2 3 6<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u524d\u7f00\u5f02\u6216\u6570\u7ec4\u4e2d\u7684\u4e24\u4e2a\u5143\u7d20\u76f8\u540c\uff0c\u5c31\u4ee3\u8868\u8fd9\u4e00\u6bb5\u5de6\u5f00\u53f3\u95ed\u533a\u95f4(5\uff0c7\uff0c2)\u7684\u5f02\u6216\u548c\u4e3a\u96f6\uff0c\u5176\u8bc1\u660e\u4e5f\u975e\u5e38\u7b80\u5355\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5047\u8bbe p[i] = p[j]\uff0c\u4e5f\u5c31\u662f a\u2081 \u2295 a\u2082 \u2295 a\u2083 \u2295 &#8230; \u2295 ai = a\u2081 \u2295 a\u2082 \u2295 a\u2083 \u2295 &#8230; \u2295 a\u1d62 \u2295 a\u1d62\u208a\u2081 \u2295 &#8230; \u2295 a\u2c7c\uff0c\u518d\u4e24\u8fb9\u540c\u65f6 \u2295 (a\u2081 \u2295 a\u2082 \u2295 a\u2083 \u2295 &#8230; \u2295 ai)\uff0c\u56e0\u4e3a\u5f02\u6216\u8fd0\u7b97\u7387\u662f\u76f8\u540c\u4e3a\u5047\uff0c\u6240\u4ee5 0 = a\u1d62\u208a\u2081 \u2295 &#8230; \u2295 a\u2c7c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\u7684\uff0c\u5982\u679c\u524d\u7f00\u5f02\u6216\u6570\u7ec4\u4e2d\u6709\u591a\u4e2a\u6570\u5b57\u76f8\u540c\uff0c\u90a3\u4e48\u4efb\u9009\u4e24\u4e2a\u76f8\u540c\u7684\u6570\u5b57\u6240\u6784\u6210\u7684\u533a\u95f4\u5185\u5f02\u6216\u548c\u90fd\u4e3a 0\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u5b9e\u8fd9\u4e9b\u4e0d\u662f\u7d2f\u52a0\u7684\u8fd0\u7b97\u540c\u6837\u53ef\u4ee5\u4f7f\u7528partial_sum\u6765\u7f16\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">partial_sum(arr.begin(), arr.end(), xorsum.begin,<br>[](int prev, int cur){<br>    return prev ^ cur<br>});<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">partial_sum\u7684\u7b2c\u56db\u4e2a\u53c2\u6570\u53ef\u4ee5\u63a5\u53d7\u4e00\u4e2a\u4e8c\u5143\u64cd\u4f5c\u51fd\u6570\uff0c\u7528\u4e8e\u8868\u793a\u5982\u4f55\u8fdb\u884c\u7edf\u8ba1\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5df2\u7ecf\u7edf\u8ba1\u7684\u7ed3\u679c\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u5f53\u524d\u5143\u7d20\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u9700\u8981 return \u4e00\u4e2a prev ^ cur \u5373\u53ef\ud83d\ude0e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\ude0b\u4e0b\u9762\u6211\u4eec\u5c06 prefix \u6269\u5c55\u5230\u66f4\u9ad8\u7ef4\u5ea6\uff0c\u6211\u4eec\u53ef\u4ee5\u7528 prefix \u7684\u601d\u60f3\u6c42\u51fa\u4e00\u4e2a\u4e8c\u7ef4\u77e9\u9635\u4e2d\u4efb\u610f\u4e00\u4e2a\u5b50\u77e9\u9635\u7684\u548c\uff0c\u6211\u4eec\u4e4b\u9700\u8981\u5148\u5bf9\u884c\u548c\u5217\u5206\u522b\u6c42\u524d\u7f00\u548c\uff0c\u8fd9\u6837\u8fd9\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u5c31\u4ee3\u8868\u4e86\u5de6\u4e0a\u89d2\u5230\u5f53\u524d\u5143\u7d20\u4f4d\u7f6e\u7684\u6240\u6709\u5143\u7d20\u4e4b\u548c\u3002\u90a3\u4e48\u6c42\u67d0\u4e2a\u5b50\u77e9\u9635\u4e4b\u548c\uff0c\u5c31\u662f\u7528\u53f3\u4e0b\u89d2\u7684\u524d\u7f00\u548c\u51cf\u53bb\u5de6\u4e0b\u89d2\u7684\u524d\u7f00\u548c\uff0c\u518d\u51cf\u53bb\u53f3\u4e0a\u89d2\u7684\u524d\u7f00\u548c\uff0c\u518d\u52a0\u4e0a\u5de6\u4e0a\u89d2\u7684\u524d\u7f00\u548c\uff08\u5176\u5b9e\u770b\u56fe\u66f4\u76f4\u89c2\u4e00\u70b9\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/8prefix%E8%AE%B2%E8%A7%A3%E9%83%A8%E5%88%86-%E4%BA%8C%E7%BB%B4prefix%E7%90%86%E8%A7%A3.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/8prefix%E8%AE%B2%E8%A7%A3%E9%83%A8%E5%88%86-%E4%BA%8C%E7%BB%B4prefix%E7%90%86%E8%A7%A3.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"8prefix\u8bb2\u89e3\u90e8\u5206-\u4e8c\u7ef4prefix\u7406\u89e3\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u80cc\u540e\u6240\u8574\u542b\u7684\u5176\u5b9e\u662f\u6570\u5b66\u96c6\u5408\u5206\u652f\u4e2d\u7684\u5bb9\u65a5\u539f\u7406\uff0c\u5927\u5bb6\u9ad8\u4e2d\u5e94\u8be5\u90fd\u5b66\u8fc7\uff0c\u90a3\u4e48\u6839\u636e\u5b83\uff0c\u6211\u4eec\u4fbf\u53ef\u4ee5\u63a8\u5e7f\u5230\u4e09\u7ef4\u751a\u81f3\u66f4\u9ad8\u7ef4\u5ea6\u7684\u524d\u7f00\u548c\uff0c\u5728\u6b64\u5c31\u4e0d\u8fc7\u591a\u8d58\u8ff0\u4e86\uff0c\u611f\u5174\u8da3\u7684\u5404\u4f4d\u53ef\u4ee5\u81ea\u884c\u5199\u4e00\u6bb5\u4ee3\u7801\u5c1d\u8bd5\u4e00\u4e0b\u66f4\u9ad8\u7ef4\u7684\u524d\u7f00\u548c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd8a\u524d\u7f00\u548c-prefix\u7ec3\u4e60<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/P12206\">-6.luogu P12206[\u84dd\u6865\u676f 2023\u56fdB] \u5f39\u73e0\u5806\u653e\ud83d\udd3a<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u9898\u662f\u4e00\u9053\u7b7e\u5230\u9898\uff0c\u8003\u5bdf\u7684\u91cd\u70b9\u5c31\u662f\u524d\u7f00\u548c\uff0c\u4ed4\u7ec6\u89c2\u5bdf\u8fd9\u4e2a\u91d1\u5b57\u5854\uff0c\u6211\u4eec\u4e0d\u96be\u53d1\u73b0\u5176\u89c4\u5f8b\uff1a\u5047\u8bbe\u6211\u4eec\u6709\u91d1\u5b57\u5854\u7684\u7b2c i \u5c42\uff0c\u90a3\u4e48\u8fd9\u4e00\u5c42\u7684\u603b\u5f39\u73e0\u6570\u5b9e\u9645\u4e0a\u7b49\u4e8e<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">((1 + i) * i) \/ 2\uff0c\u662f\u4e00\u4e2a\u7b49\u5dee\u6570\u5217\u3002\u56e0\u4e3a\u662f\u4e00\u9053\u586b\u7a7a\u9898\uff0c\u6240\u4ee5\u601d\u8def\u4e5f\u5341\u5206\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u5f88\u5927\u7684\u6570 n \uff0c\u786e\u4fdd\u91d1\u5b57\u5854\u7edd\u5bf9\u4e0d\u53ef\u80fd\u5230\u8fbe\u7b2c n \u5c42\uff0c\u518d\u5bf9\u5f62\u5982<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\uff0c2\uff0c3\uff0c4\uff0c5\uff0c6\uff0c7\uff0c8\uff0c9&#8230;\u7684\u6570\u7ec4\u505a\u4e24\u6b21\u524d\u7f00\u548c\u5373\u53ef\uff0c\u6700\u540e\u904d\u5386\u6570\u7ec4\uff0c\u5982\u679c\u6570\u7ec4\u5143\u7d20\u5927\u4e8etarget\uff0c\u8f93\u51fa\u5176\u524d\u4e00\u4e2a\u5143\u7d20\u7684\u4e0b\u6807\u5373\u53ef\uff0c\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include&lt;bits\/stdc++.h&gt;<br>using namespace std;<br>int main(void){<br> &nbsp; &nbsp;ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);<br> &nbsp; &nbsp;int n = 10000;              \/\/\u8bbe\u7f6e\u4e00\u4e2a\u5f88\u5927\u7684 n<br> &nbsp; &nbsp;int target = 20230610;      \/\/\u76ee\u6807\u503c<br> &nbsp; &nbsp;vector&lt;int&gt; a(n);           <br> &nbsp; &nbsp;iota(a.begin(), a.end(), 0);    \/*iota\u662f\u4f4d\u4e8e&lt;algorithm&gt;\u4e2d\u7684\u51fd\u6570\uff0c\u5176\u4e09\u4e2a\u53c2\u6570\u5206\u522b\u4e3a\u3010\u8d77\u59cb\u4f4d\u7f6e\u3011\u3010\u7ec8\u6b62\u4f4d\u7f6e\u3011\u3010\u521d\u59cb\u503c\u3011\uff0ciota\u4f1a\u4ece\u521d\u59cb\u503c\u5f00\u59cb\uff0c\u6309\u7167\u6307\u5b9a\u7684\u6b65\u957f\uff08\u9ed8\u8ba4\u4e3a1\uff09\u9012\u589e\uff0c\u76f4\u5230\u8fbe\u5230\u6216\u8d85\u8fc7\u7ed3\u675f\u8fed\u4ee3\u5668*\/<br> &nbsp; &nbsp;partial_sum(a.begin(), a.end(), a.begin()); <br> &nbsp; &nbsp;partial_sum(a.begin(), a.end(), a.begin());<br> &nbsp; &nbsp;for(int i = 0; i &lt;= n; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp;if(a[i] &gt; target){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cout &lt;&lt; i - 1 &lt;&lt; endl;      \/\/a[i] &gt; target \u8bf4\u660e\u65e0\u6cd5\u642d\u6210\u8fd9\u4e00\u5c42\uff0c\u6240\u4ee5\u8f93\u51fa\u4e0a\u4e00\u5c42\u7684\u4e0b\u6807<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;return 0;<br>}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/leetcode.cn\/problems\/trapping-rain-water\/description\/\">-7.LeetCode 42.\u63a5\u96e8\u6c34\ud83d\udca7<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bd2\u7624\u9762\u8bd5\u9898\uff0c\u67d0\u4e2a\u5927\u5382<del>(ByteDance)<\/del>\u6700\u559c\u6b22\u8003\u5bdf\u7684\u7b97\u6cd5\u9898\uff0c\u5176\u5728LeetCode\u4e0a\u4f5c\u4e3a\u7ea2\u9898\uff0c\u6b63\u786e\u7387\u5374\u5df2\u7ecf\u8fbe\u5230\u4e86\u60ca\u4eba\u768465.7%\uff0c\u8db3\u53ef\u89c1\u8fd9\u9053\u9898\u88ab\u591a\u5c11\u4eba\u5237\u8fc7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u6211\u4eec\u6765\u770b\u8fd9\u9053\u9898\uff0c\u4ee5LeetCode\u4e0a\u7684\u56fe\u7247\u4e3a\u4f8b\uff0c\u5982\u679c\u4e00\u4e2a\u4f4d\u7f6e\u53ef\u4ee5\u5bb9\u7eb3\u96e8\u6c34\uff0c\u90a3\u4e48\u5b83\u7684\u4e24\u4fa7\u5fc5\u987b\u8981\u6709\u9ad8\u4e8e\u5b83\u7684\u67f1\u5b50\uff0c\u8fd9\u4e2a\u4f4d\u7f6e\u5177\u4f53\u80fd\u5bb9\u7eb3\u591a\u5c11\u96e8\u6c34\uff0c\u53d6\u51b3\u4e8e\u5176\u5de6\u53f3\u4e24\u4fa7\u5404\u81ea\u6700\u9ad8\u7684\u67f1\u5b50\u53d6\u6700\u5c0f\u503c\u518d\u51cf\u53bb\u8fd9\u4e2a\u4f4d\u7f6e\u67f1\u5b50\u7684\u9ad8\u5ea6\uff0c\u5728\u56fe\u4e2d\uff0c\u9ed1\u8272\u7684\u90e8\u5206\u4e3a\u67f1\u5b50\uff0c\u84dd\u8272\u7684\u90e8\u5206\u4e3a\u96e8\u6c34\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/9LeetCode%E6%8E%A5%E9%9B%A8%E6%B0%B4png.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/9LeetCode%E6%8E%A5%E9%9B%A8%E6%B0%B4png.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"9LeetCode\u63a5\u96e8\u6c34png\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u4f4d\u7f6e5\u7684\u96e8\u6c34\u91cf\u5c31\u7b49\u4e8emin(\u5de6\u8fb9\u67f1\u5b50\u7684\u6700\u5927\u503c\uff0c\u53f3\u8fb9\u67f1\u5b50\u7684\u6700\u5927\u503c)\uff0c\u5373min(\u4f4d\u7f6e3\uff0c\u4f4d\u7f6e7)=2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff0c\u6240\u4ee55\u4f4d\u7f6e\u7684\u6c34\u91cf\u4e3a2 &#8211; 0 = 2\u3002\u601d\u8def\u5df2\u7ecf\u6e05\u6670\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u8981\u89e3\u51b3\u7684\u5c31\u662f\u4efb\u610f\u4f4d\u7f6e\u5176\u5de6\u53f3\u4e24\u4fa7\u7684\u6700\u5927\u67f1\u5b50\u9ad8\u5ea6\uff0c\u6211\u4eec\u53ef\u4ee5\u5148\u4ece\u524d\u5411\u540e\u904d\u5386\uff0c\u627e\u51fa\u5de6\u4fa7\u5230\u8fd9\u4e2a\u4f4d\u7f6e\u7684\u6700\u9ad8\u67f1\u5b50<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff0c\u518d\u4ece\u540e\u5411\u524d\u904d\u5386\uff0c\u627e\u51fa\u53f3\u4fa7\u5230\u8fd9\u4e2a\u4f4d\u7f6e\u7684\u6700\u9ad8\u67f1\u5b50\u3002\u53d6min\u4e4b\u540e\u518d\u51cf\u53bb\u5f53\u524d\u4f4d\u7f6e\u7684\u67f1\u5b50\u9ad8\u5ea6\u5373\u53ef\u3002\u5176\u4ed6\u601d\u8def\u5341\u5206\u7b80\u5355\uff0c\u5c31\u4e0d\u591a\u8d58\u8ff0\u4e86\u3002\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Solution {<br>public:<br> &nbsp; &nbsp;int trap(vector&lt;int&gt;&amp; height) {<br> &nbsp; &nbsp; &nbsp; &nbsp;int n = height.size();<br> &nbsp; &nbsp; &nbsp; &nbsp;int ans = 0;<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;int&gt; leftMax(n), rightMax(n); &nbsp; &nbsp;\/\/\u5f00\u4e24\u4e2avector<br> &nbsp; &nbsp; &nbsp; &nbsp;leftMax[0] = height[0], rightMax[n - 1] = height[n - 1];    \/\/\u521d\u59cb\u5316\u8fb9\u754c\uff0c\u9632\u6b62\u8d8a\u754c\u3002\uff08\u8bb0\u5f97\u5904\u7406\u8fb9\u754c\u95ee\u9898\uff09<br> &nbsp; &nbsp; &nbsp; &nbsp;for (int i = 1; i &lt; n; i++) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;leftMax[i] = max(leftMax[i - 1],height[i]);             \/\/\u4ece\u524d\u5f80\u540e\u904d\u5386<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;for(int i = n - 2; i &gt;= 0; i--){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rightMax[i] = max(rightMax[i + 1], height[i]);          \/\/\u4ece\u540e\u5f80\u524d\u904d\u5386<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0; i &lt; n; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ans += min(leftMax[i], rightMax[i]) - height[i];        \/\/ans\u8bb0\u5f55\u96e8\u6c34\u603b\u548c<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return ans;<br> &nbsp;  }<br>};<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/10LeetCode%E6%8E%A5%E9%9B%A8%E6%B0%B4AC.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/picbeds-1403930428.cos.ap-beijing.myqcloud.com\/%E7%AE%97%E6%B3%95%E6%80%9D%E6%83%B3\/10LeetCode%E6%8E%A5%E9%9B%A8%E6%B0%B4AC.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"10LeetCode\u63a5\u96e8\u6c34AC\"\/><\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd5\u5dee\u5206<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\u867d\u7136\u5355\u72ec\u62c6\u5206\u51fa\u6765\u4f5c\u4e3a\u4e00\u4e2a\u7b97\u6cd5\uff0c\u4f46\u5fc5\u987b\u5f3a\u8c03\u7684\u662f\uff0c&#8221;\u5dee\u5206&#8221;\u672c\u8d28\u4e0a\u662f&#8221;\u524d\u7f00\u548c&#8221;\u7684<strong>\u9006\u8fd0\u7b97<\/strong>\uff0c\u5176\u662f\u4e00\u79cd\u5feb\u901f\u5904\u7406\u533a\u95f4\u52a0\u51cf\u64cd\u4f5c\u7684\u7b97\u6cd5\uff0c\u90a3\u4e48\u5230\u5e95\u4ec0\u4e48\u662f\u5dee\u5206\u5462\uff1f<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mrow><mtext>\u524d<\/mtext><mtext>\u7f00<\/mtext><mtext>\u548c<\/mtext><mtext>&nbsp;<\/mtext><msub><mi>S<\/mi><mi>i<\/mi><\/msub><mtext>&nbsp;<\/mtext><mo>=<\/mo><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mtable><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mi>i<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mo>+<\/mo><msub><mi>s<\/mi><mrow><mi>i<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/msub><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mi>i<\/mi><mo>&gt;<\/mo><mn>0<\/mn><\/mrow><\/mtd><\/mtr><\/mtable><mo fence=\"true\" form=\"postfix\"><\/mo><\/mrow><\/mrow><annotation encoding=\"application\/x-tex\">\u524d\u7f00\u548c\\ S_i\\ = \\begin{cases} a_i\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ i=0 \\\\ a_i+s_{i-1}\\ \\ \\ \\ \\ \\ i&gt;0 \\end{cases}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mrow><mtext>\u5dee<\/mtext><mtext>\u5206<\/mtext><mtext>&nbsp;<\/mtext><msub><mi>d<\/mi><mi>i<\/mi><\/msub><mtext>&nbsp;<\/mtext><mo>=<\/mo><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mtable><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mi>i<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mo>\u2212<\/mo><msub><mi>a<\/mi><mrow><mi>i<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/msub><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mi>i<\/mi><mo>&gt;<\/mo><mn>0<\/mn><\/mrow><\/mtd><\/mtr><\/mtable><mo fence=\"true\" form=\"postfix\"><\/mo><\/mrow><\/mrow><annotation encoding=\"application\/x-tex\">\u5dee\u5206\\ d_i\\ = \\begin{cases} a_i\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ i=0 \\\\ a_i-a_{i-1}\\ \\ \\ \\ \\ \\ i&gt;0 \\end{cases}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u663e\u7136\uff0c\u5dee\u5206\u5c31\u662f\u5bf9\u67d0\u4e9b\u5143\u7d20\u51cf\u53bb\u524d\u4e00\u4e2a\u5143\u7d20\u7684\u503c\uff0c\u4e5f\u5c31\u662f\u8ba1\u7b97\u76f8\u90bb\u4e24\u4e2a\u6570\u7684\u5dee\uff0c\u56e0\u6b64\u53eb\u505a\u5dee\u5206\u3002\u5dee\u5206\u7684\u5199\u6cd5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for(int i = n - 1; i &gt;= 0; i--){<br> &nbsp; &nbsp;if(i == 0) d[i] = a[i];<br> &nbsp; &nbsp;else d[i] = a[i] - a[i - 1];<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728C++\u6807\u51c6\u5e93\u4e2d\u4e5f\u6709\u4e00\u4e2a\u51fd\u6570<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adjacent_difference(a.begin(), a.end(), d.begin());<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4f7f\u7528\u65b9\u6cd5\u548cpartial_sum\u7c7b\u4f3c\uff0c\u5728\u6b64\u5c31\u4e0d\u518d\u8d58\u8ff0\u4e86<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u63a8\u8bba\uff1a\u5bf9\u533a\u95f4 [l , r] \u533a\u95f4\u5185\u6bcf\u4e2a\u5143\u7d20\u90fd\u589e\u52a0 k\uff0c\u7b49\u4ef7\u4e8e\u5bf9\u5dee\u5206\u6570\u7ec4 l \u7684\u4f4d\u7f6e\u589e\u52a0 k \uff0cr + 1 \u7684\u4f4d\u7f6e\u51cf k\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u4e3e\u4e00\u4e2a\u4f8b\u5b50\u6765\u770b\u770b\u8fd9\u4e2a\u63a8\u8bba\u6709\u4ec0\u4e48\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5047\u8bbe\u539f\u6570\u7ec4\u4e3a 1 2 3 4 5\uff0c\u6211\u4eec\u60f3\u5728 0 ~ 3 \u7684\u533a\u95f4\u90fd +2 \uff0c\u663e\u7136\u6734\u7d20\u7684\u505a\u6cd5\u662f\u679a\u4e3e0 ~ 3 \u4f4d\u7f6e\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u52a02\uff0c\u8fd9\u6837\u7ecf\u8fc7 m \u6b21\u67e5\u8be2\u540e\uff0c\u590d\u6742\u5ea6\u662fO(n * m),\u5728\u6570\u636e\u8303\u56f4\u8f83\u5927\u7684\u65f6\u5019\u663e\u7136\u592a\u6162\u4e86\uff0c1 2 3 4 5\u5bf9\u5e94\u7684\u5dee\u5206\u6570\u7ec4\u4e3a 1 1 1 1 1 -5\uff08\u4e3a\u4e86\u9632\u6b62\u8d8a\u754c\uff0c\u53ef\u4ee5\u591a\u5f00\u4e00\u4f4d\uff09,\u533a\u95f4\u4fee\u6539\u540e\u7684\u539f\u6570\u7ec4\u4e3a 3 4 5 6 5\uff0c\u5bf9\u5e94\u7684\u5dee\u5206\u6570\u7ec4\u4e3a 3 1 1 1 -1 -5, \u53ef\u4ee5\u53d1\u73b0\uff0c[0 , 3] \u533a\u95f4\u52a02\u7684\u64cd\u4f5c\uff0c\u5bf9\u5e94\u7684\u5c31\u662f\u5728\u5dee\u5206\u6570\u7ec4 0 \u7684\u4f4d\u7f6e\u52a0 2 \uff0c4 \u7684\u4f4d\u7f6e &#8211; 2\u3002\u8fd9\u610f\u5473\u7740\u6bcf\u6b21\u4fee\u6539\u6211\u4eec\u90fd\u53ea\u9700\u8981\u4ee5O(1)\u7684\u590d\u6742\u5ea6\u6539\u4e24\u4e2a\u4f4d\u7f6e\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u5bf9\u539f\u6570\u7ec4\u5148\u8fdb\u884c\u4e00\u6b21\u5dee\u5206\uff0c\u518d\u8fdb\u884c\u4fee\u6539\uff0c\u6700\u540e\u8fdb\u884c\u524d\u7f00\u548c\u8fd8\u539f\u4e3a\u539f\u6570\u7ec4\uff0c\u590d\u6742\u5ea6\u7531O(n * m)\u964d\u4f4e\u5230\u4e86O(n + m)\uff0c\u53ef\u559c\u53ef\u8d3a\uff01\ud83e\udd70<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba9\u6211\u4eec\u7ee7\u7eed\u63a8\u5e7f\u5230\u4e8c\u4f4d\u5dee\u5206\u6570\u7ec4\uff0c\u5982\u679c\u6211\u4eec\u5bf9(x\u2081,y\u2081)\u5230(x\u2082,y\u2082)\u7684\u533a\u95f4\u90fd +k\uff0c\u5c31\u7b49\u4ef7\u4e8e\u5bf9\u5dee\u5206\u6570\u7ec4\u4e2d(x\u2081,y\u2081) +k\uff0c(x\u2082+1,y\u2082+1) +k\uff0c(x\u2081,y\u2082+1) -k\uff0c(x\u2082+1,y\u2081) -k\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5c06\u539f\u672c\u9700\u8981n^2\u7684\u679a\u4e3e\u4fee\u6539\uff0c\u4f18\u5316\u5230\u4e86O(1)\u7684\u590d\u6742\u5ea6\uff0c\u53ef\u559c\u53ef\u8d3a\uff01\uff01\uff01\ud83e\udd70\ud83e\udd70\ud83e\udd70<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd8a\u5dee\u5206\u7ec3\u4e60<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/P9094\">-8.Potyczki Algorytmiczne 2020 KOL <strong>\u2764<\/strong>\ud83d\udc9b\ud83d\udc99<\/a>&#8211;<\/h4>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u539f\u9898\u94fe\u63a5: <a href=\"https:\/\/pan.baidu.com\/s\/1x7WcXFJATeGxC-wm_XmxVw?pwd=0721\">https:\/\/pan.baidu.com\/s\/1x7WcXFJATeGxC-wm_XmxVw?pwd=0721<\/a> \u63d0\u53d6\u7801: 0721<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/P13879\">-9.luogu P13879[\u84dd\u6865\u676f 2023\u7701JAVA A] \u68cb\u76d8\u26ab\u26aa\ufe0f<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6316\u4e2a\u5751\u5728\u8fd9\u91cc\uff01<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/P10903\">-10.luogu P10903[\u84dd\u6865\u676f 2024\u7701C++ C]\u5546\u54c1\u5e93\u5b58\u7ba1\u7406\ud83d\udce6\ufe0f<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6316\u4e2a\u5751\u5728\u8fd9\u91cc\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd5*\u5355\u8c03\u6027\u679a\u4e3e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6316\u4e2a\u5751\u5728\u8fd9\u91cc\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Part 2 : \u8d2a\u5fc3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd5\u8d2a\u5fc3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u6709\u65e0\u9650\u591a\u7684\u6570\u5b57 5 5 5 5 5 5 5 &#8230; ; 2 2 2 2 2 2 2&#8230; ; 1 1 1 1 1 1 1 &#8230; ;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u4f55\u9009\u62e9<strong>\u6700\u5c11\u7684\u6570\u5b57<\/strong>\uff0c\u8ba9\u9009\u62e9\u7684\u6570\u5b57\u4e4b\u548c n \u6070\u597d\u6ee1\u8db3 n == 27\uff1f\u6700\u7b26\u5408\u6211\u4eec\u76f4\u89c9\u7684\u7b56\u7565\u5c31\u662f\u5148\u8d2a\u5fc3\u62ff\u6700\u5927\u7684\u6570\u5b57\uff0c\u76f4\u5230\u63a5\u8fd1 n \u4f46\u4e0d\u8d85\u8fc7 n \uff0c\u7136\u540e\u5269\u4e0b\u7684\u518d\u7528\u540c\u6837\u7684\u65b9\u5f0f\u7528\u66f4\u5c0f\u7684\u6570\u5b57\u586b\u8865\u7a7a\u7f3a\uff0c\u4e5f\u5c31\u662f\u9700\u89815\u4e2a5\u548c1\u4e2a2\uff0c\u8fd9\u4e2a\u601d\u60f3\u5bf9\u4e8e\u8fd9\u7ec4\u6570\u5b57\u6765\u8bf4\u662f\u6b63\u786e\u7684\uff0c\u4f46\u662f\u5bf9\u4e8e\u8fd9\u4e2a\u6a21\u578b\u6765\u8bf4\u662f\u6d45\u663e\u7684\u3001\u9519\u8bef\u7684\u3002\u90a3\u4e48\u7a76\u7adf\u4ec0\u4e48\u662f\u8d2a\u5fc3\u5462\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u8ba9\u6211\u4eec\u5bf9\u8d2a\u5fc3\u4e0b\u4e00\u4e2a\u5b9a\u4e49\ud83d\udc47<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u4ece <strong>\u521d\u59cb\u72b6\u6001<\/strong> \u5230 <strong>\u76ee\u6807\u72b6\u6001<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6c42\u4e00\u4e2a <strong>\u6700\u4f73\u65b9\u6848<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709\u591a\u4e2a <strong>\u72b6\u6001\u8f6c\u79fb<\/strong> \u65b9\u5f0f \uff08\u6539\u53d8\u5f53\u524d\u72b6\u6001\u7684\u65b9\u5f0f\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><u>\u4ec5\u6839\u636e<\/u><\/strong> <strong>\u5f53\u524d\u72b6\u6001<\/strong> \u6765\u5236\u5b9a\u7684 <strong>\u7b56\u7565<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u79f0\u4e4b\u4e3a <strong>\u8d2a\u5fc3<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">emm&#8230;\u6709\u70b9\u770b\u4e0d\u61c2\uff0c\u8fd9\u4e9b\u540d\u8bcd\u90fd\u662f\u4ec0\u4e48\u610f\u601d\uff1f\u90a3\u5c31\u8ba9\u6211\u4eec\u4ee5\u521a\u624d\u90a3\u4e2a\u95ee\u9898\u4e3a\u4f8b\u8fdb\u884c\u89e3\u91ca<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u72b6\u6001\uff1a\u5df2\u9009\u62e9\u6570\u5b57\u4e4b\u548c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u521d\u59cb\u72b6\u6001\uff1a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u6807\u72b6\u6001\uff1an<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u4f18\u65b9\u6848\uff1a\u4e2a\u6570\u6700\u5c11<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u72b6\u6001\u8f6c\u79fb\uff1a+1,+2,+5<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b56\u7565\uff1a<strong>\u4ec5\u6839\u636e<\/strong>\u5f53\u524d\u7684\u548c\uff0c\u4f18\u5148\u9009\u6700\u5927\u7684\u6570<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u6982\u5ff5\u90fd\u6e05\u695a\u4e4b\u540e\uff0c\u6211\u4eec\u4e0d\u59a8\u91cd\u65b0\u5ba1\u89c6\u6211\u4eec\u4e4b\u524d\u8d2a\u5fc3\u7684\u7b56\u7565\uff0c\u7b26\u5408\u6211\u4eec\u76f4\u89c9\u7684\u7b56\u7565\u5c31\u662f\u5148\u8d2a\u5fc3\u62ff\u6700\u5927\u7684\u6570\u5b57\uff0c\u4f46\u6211\u4eec\u5e94\u8be5\u5982\u4f55\u8bc1\u660e\u6211\u4eec\u7684\u7b56\u7565\u662f\u6b63\u786e\u7684\u5462\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u6765\u5c1d\u8bd5\u7740\u8bc1\u660e\u4e00\u4e0b\uff1a\u56e0\u4e3a\u6211\u4eec\u662f\u62ff\u6700\u5927\u7684\u6570\u5b57\uff0c\u76f4\u5230\u63a5\u8fd1 n \u4f46\u4e0d\u8d85\u8fc7 n \uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u53cd\u8bc1\u6cd5\uff0c\u8bbe\u5f53\u524d\u72b6\u6001\u4e3ax\uff0cx+5\u2264n\uff0c\u6839\u636e\u6211\u4eec\u7684\u7b56\u7565\uff0c\u5e94\u8be5\u90095\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u6211\u4eec\u5047\u8bbe\uff1a\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6709\u6bd4\u90095\u66f4\u597d\u7684\u65b9\u6848\uff0c\u6bd4\u5982\u9009\u62e92\uff0c\u518d\u5047\u8bbe\u9009\u62e9\u4e862\u540e\uff0c\u540e\u7eed\u8fd8\u4f1a\u90095\uff0c\u7531\u4e8e\u9009\u62e9\u987a\u5e8f\u6ca1\u6709\u5173\u7cfb\uff0c\u6240\u4ee5\u5148\u90092\u518d\u90095\u548c\u5148\u90095\u518d\u90092\u662f\u7b49\u4ef7\u7684\uff0c\u56e0\u6b64\u8fd9\u4e2a\u5047\u8bbe\u4e0b\u90092\u5e76\u4e0d\u6bd4\u90095\u66f4\u597d\uff0c\u5047\u8bbe\u4e0d\u6210\u7acb\u274c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u6211\u4eec\u770b\u53e6\u5916\u7684\u60c5\u51b5\uff0c\u5728\u6211\u4eec\u9009\u4e862\u4e4b\u540e\uff0c\u5269\u4e0b\u7684\u72b6\u6001\u8f6c\u79fb\u53ea\u5269\u4e0b+2\u548c+1\uff0c\u56e0\u4e3ax + 5 \u2264 n\uff0c \u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5047\u8bbe\u76ee\u6807\u662fn = x+5\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6700\u4f18\u89e3\u4e3a|+2,+2,+1|,\u6bd4\u76f4\u63a5\u90095\u5dee\uff0c\u6240\u4ee5\u4e0d\u6210\u7acb<\/li>\n\n\n\n<li>\u5047\u8bbe\u76ee\u6807\u662fn = x+6\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6700\u4f18\u89e3\u4e3a|+2,+2,+2|,\u6bd4|+5,+1|\u5dee\uff0c\u6240\u4ee5\u4e0d\u6210\u7acb<\/li>\n\n\n\n<li>\u5047\u8bbe\u76ee\u6807\u662fn = x+5+2i\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6700\u4f18\u89e3\u5c31\u662f\u5728n = x+5\u7684\u57fa\u7840\u4e0a\u518d\u9009 i \u4e2a2,\u4e00\u5171\u9700\u89813 + i\u4e2a\u6570\uff0c\u6bd4\u90095\u540e\u518d\u9009 i \u4e2a 2\uff0c\u4e5f\u5c31\u662f1 + i\u4e2a\u6570\u8981\u5dee\uff0c\u6240\u4ee5\u4e0d\u6210\u7acb<\/li>\n\n\n\n<li>\u540c\u7406\u53ef\u8bc1n = x+6+2i\u4e5f\u4e0d\u6210\u7acb<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\u5728\u8fd9\u4e2a\u60c5\u51b5\u4e0b\uff0c\u9009 2 \u90fd\u4e0d\u53ef\u80fd\u4f1a\u6bd4\u9009 5 \u8981\u597d\uff0c\u540c\u7406\u4e5f\u53ef\u8bc1\u660e\u90091\u4e5f\u4e0d\u4f1a\u6bd4\u90095\u8981\u597d\uff0c\u6240\u4ee5\u5728x+5\u2264n\u65f6\uff0c\u90095\u662f\u6700\u4f18\u89e3\u3002<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mrow><mi>x<\/mi><mo form=\"prefix\" stretchy=\"false\">(<\/mo><mi>x<\/mi><mo>+<\/mo><mn>5<\/mn><mo>\u2264<\/mo><mi>n<\/mi><mo form=\"postfix\" stretchy=\"false\">)<\/mo><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mtable><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>+<\/mo><mn>5<\/mn><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mo form=\"prefix\" stretchy=\"false\">(<\/mo><mtext>\u5e94<\/mtext><mtext>\u8be5<\/mtext><mtext>\u9009<\/mtext><mn>5<\/mn><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>+<\/mo><mn>2<\/mn><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mtable><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>+<\/mo><mn>5<\/mn><mtext>\u274c<\/mtext><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>+<\/mo><mn>2<\/mn><mo separator=\"true\">,<\/mo><mo form=\"prefix\" stretchy=\"false\">+<\/mo><mn>1<\/mn><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mtable><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mi>n<\/mi><mo>=<\/mo><mi>x<\/mi><mo>+<\/mo><mn>5<\/mn><mo separator=\"true\">,<\/mo><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mi>|<\/mi><mo>+<\/mo><mn>2<\/mn><mo separator=\"true\">,<\/mo><mo form=\"prefix\" stretchy=\"false\">+<\/mo><mn>2<\/mn><mo separator=\"true\">,<\/mo><mo form=\"prefix\" stretchy=\"false\">+<\/mo><mn>1<\/mn><mi>|<\/mi><mtext>&nbsp;<\/mtext><mo>&gt;<\/mo><mtext>&nbsp;<\/mtext><mi>|<\/mi><mo>+<\/mo><mn>5<\/mn><mi>|<\/mi><mtext>\u274c<\/mtext><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mi>n<\/mi><mo>=<\/mo><mi>x<\/mi><mo>+<\/mo><mn>6<\/mn><mo separator=\"true\">,<\/mo><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mi>|<\/mi><mo>+<\/mo><mn>2<\/mn><mo separator=\"true\">,<\/mo><mo form=\"prefix\" stretchy=\"false\">+<\/mo><mn>2<\/mn><mo separator=\"true\">,<\/mo><mo form=\"prefix\" stretchy=\"false\">+<\/mo><mn>2<\/mn><mi>|<\/mi><mtext>&nbsp;<\/mtext><mo>&gt;<\/mo><mtext>&nbsp;<\/mtext><mi>|<\/mi><mo>+<\/mo><mn>5<\/mn><mo separator=\"true\">,<\/mo><mo form=\"prefix\" stretchy=\"false\">+<\/mo><mn>1<\/mn><mi>|<\/mi><mtext>\u274c<\/mtext><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mi>n<\/mi><mo>=<\/mo><mi>x<\/mi><mo>+<\/mo><mn>5<\/mn><mo>+<\/mo><mn>2<\/mn><mi>i<\/mi><mo separator=\"true\">,<\/mo><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mn>3<\/mn><mo>+<\/mo><mi>i<\/mi><mtext>&nbsp;<\/mtext><mo>&gt;<\/mo><mtext>&nbsp;<\/mtext><mn>1<\/mn><mo>+<\/mo><mi>i<\/mi><mtext>\u274c<\/mtext><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mi>n<\/mi><mo>=<\/mo><mi>x<\/mi><mo>+<\/mo><mn>6<\/mn><mo>+<\/mo><mn>2<\/mn><mi>i<\/mi><mo separator=\"true\">,<\/mo><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mn>3<\/mn><mo>+<\/mo><mi>i<\/mi><mtext>&nbsp;<\/mtext><mo>&gt;<\/mo><mtext>&nbsp;<\/mtext><mn>2<\/mn><mo>+<\/mo><mi>i<\/mi><mtext>\u274c<\/mtext><\/mrow><\/mtd><\/mtr><\/mtable><mo fence=\"true\" form=\"postfix\"><\/mo><\/mrow><\/mrow><\/mtd><\/mtr><\/mtable><mo fence=\"true\" form=\"postfix\"><\/mo><\/mrow><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>+<\/mo><mn>1<\/mn><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><mtext>\u274c<\/mtext><mtext>\u540c<\/mtext><mtext>\u7406<\/mtext><mtext>\u53ef<\/mtext><mtext>\u8bc1<\/mtext><\/mrow><\/mtd><\/mtr><\/mtable><mo fence=\"true\" form=\"postfix\"><\/mo><\/mrow><\/mrow><annotation encoding=\"application\/x-tex\">x(x+5\\leq n) \\begin{cases} +5\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ (\u5e94\u8be5\u90095)\\\\ \\\\+2 \\begin{cases} +5\u274c\\\\ \\\\+2,+1 \\begin{cases} n=x+5,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ |+2,+2,+1|\\ &gt;\\ |+5|\u274c\\\\  n=x+6,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ |+2,+2,+2|\\ &gt;\\ |+5,+1|\u274c\\\\ n=x+5+2i,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 3+i\\ &gt;\\ 1+i\u274c\\\\ n=x+6+2i,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 3+i\\ &gt;\\ 2+i\u274c \\end{cases} \\end{cases} \\\\ \\\\ +1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \u274c\u540c\u7406\u53ef\u8bc1 \\end{cases}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u521a\u624d\u5728\u505a\u7684\u4e8b\uff0c\u5176\u5b9e\u662f\u5927\u5bb6\u521d\u5b66\u8d2a\u5fc3\u7b97\u6cd5\u65f6\u6781\u5176\u5bb9\u6613\u5ffd\u7565\uff0c\u4f46\u5374\u662f\u6700\u91cd\u8981\u7684\u4e00\u90e8\u5206\u3002\u5c06\u9898\u76ee\u7a0d\u52a0\u6539\u52a8\uff0c\u6bcf\u6b21\u9009\u62e9\u7684\u6570\u5b57\u4ece1\u30012\u30015\u6539\u4e3a1\u30013\u30014\u30015\uff0c\u5e76\u4e14\u76ee\u6807\u6539\u6210n == 7,\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6839\u636e\u6211\u4eec\u7684\u7b56\u7565\uff0c\u4f1a\u9009\u62e95\u30011\u30011\uff0c\u4f46\u66f4\u4f18\u89e3\u662f3\u30014\uff0c\u663e\u7136\u7b56\u7565\u4e0d\u6210\u7acb\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u6b64\uff0c\u6211\u4eec\u4fbf\u53ef\u4ee5\u5927\u81f4\u4e86\u89e3\u8d2a\u5fc3\u95ee\u9898\u7684\u89e3\u9898\u6b65\u9aa4<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5236\u5b9a\u67d0\u4e2a\u8d2a\u5fc3\u7684\u7b56\u7565<\/li>\n\n\n\n<li>\u8bc1\u660e\u8fd9\u4e2a\u7b56\u7565\u7684\u6b63\u786e\u6027<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e25\u8c28\u7684\u8bb2\uff0c\u8d2a\u5fc3\u5e76\u4e0d\u662f\u4e00\u79cd\u4e25\u683c\u610f\u4e49\u4e0a\u7684\u7b97\u6cd5\uff0c\u800c\u662f\u4e00\u4e2a\u601d\u60f3\u6216\u8005\u7b56\u7565\uff0c\u5b83\u6ca1\u6709\u5177\u4f53\u7684\u6a21\u677f\u548c\u6a21\u578b\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u7ecf\u5178\u7684\u8d2a\u5fc3\u4f8b\u5b50\uff0c\u6765\u5bfb\u627e\u4e00\u4e9b\u542f\u53d1\uff0c\u7531\u6b64\u6765\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u627e\u5230\u5982\u4f55\u5236\u5b9a\u8d2a\u5fc3\u7684\u7b56\u7565\uff0c\u4ee5\u53ca\u5982\u4f55\u5feb\u901f\u8bc1\u660e\u5176\u6b63\u786e\u6027\u3002\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u770b\u4e24\u4e2a\u6bd4\u8f83\u7ecf\u5178\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u96c6\u5408\u9009\u62e9\u95ee\u9898(\u957f\u6587\u672c\u8b66\u544a)<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709 n \u4e2a\u5f00\u533a\u95f4[l\u1d62,r\u1d62]\uff0c\u5728\u4fdd\u8bc1\u9009\u62e9\u7684\u533a\u95f4\u4e24\u4e24\u4e0d\u91cd\u53e0\u7684\u524d\u63d0\u4e0b\uff0c\u9009\u62e9\u5c3d\u91cf\u591a\u7684\u533a\u95f4<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[4,6] [6,8] [2,5] [3,6] [1,3] [5,6] [0,8] [4,5]\uff0c\u6bd4\u5982\u5728\u8fd9 8 \u4e2a\u533a\u95f4\u4e2d\u9009\u62e9\u6700\u591a\u7684\u533a\u95f4\uff0c\u662f\u4ed6\u4eec\u4e92\u4e0d\u91cd\u53e0\uff0c\u7531\u4e8e\u533a\u95f4\u7684\u9009\u62e9\u987a\u5e8f\u65e0\u5173\uff0c\u6240\u4ee5\u6211\u4eec\u60f3\u5230\u53ef\u4ee5\u5148\u8fdb\u884c\u6392\u5e8f\uff0c\u6bd4\u5982\u6211\u4eec\u4ee5\u5de6\u7aef\u70b9\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff0c\u5f97\u5230[0,8] [1,3] [2,5] [3,6] [4,5] [4,6] [5,6] [6,8]\uff0c\u7136\u540e\u4f9d\u6b21\u9009\u62e9\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0\u6709\u4e00\u4e2a\u7279\u522b\u957f\u7684\u533a\u95f4[0,8]\u4f1a\u88ab\u7b2c\u4e00\u65f6\u95f4\u9009\u62e9\uff0c\u5c31\u65e0\u6cd5\u9009\u62e9\u5176\u4ed6\u533a\u95f4\u4e86\uff0c\u663e\u7136\u8fd9\u4e48\u505a\u4e0d\u5bf9\u3002\u6211\u4eec\u518d\u5c1d\u8bd5\u4ee5\u53f3\u7aef\u70b9\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff0c\u5f97\u5230[1,3] [2,5] [4,5] [3,6] [4,6] [5,6] [0,8] [6,8]\uff0c\u7136\u540e\u4f9d\u6b21\u9009\u62e9\uff1a\u9009\u62e9[1,3]\uff0c\u53bb\u6389\u5728\u96c6\u5408\u533a\u95f4\u5185\u4e0e\u5b83\u6709\u91cd\u53e0\u7684\u533a\u95f4\uff0c\u5f97\u5230[4,5] [3,6] [4,6] [5,6] [6,8]\uff0c\u518d\u5728\u5269\u4f59\u7684\u533a\u95f4\u4e2d\u9009\u62e9\u7b2c\u4e00\u4e2a[4,5]\uff0c\u518d\u6b21\u53bb\u91cd\uff0c\u5f97\u5230[5,6] [6,8]\uff0c\u9009\u62e9[5,6]\uff0c\u5f97\u5230[6,8]\uff0c\u6700\u540e\u9009\u62e9[6,8]\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u83b7\u5f97\u4e86[1,3] [4,5] [5,6] [6,8]\uff0c\u8fd9\u6837\u5b50\u770b\u8d77\u6765\u662f\u6b63\u786e\u7684\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u8fdb\u884c\u8bc1\u660e\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u548c\u533a\u95f40\u4e0d\u76f8\u4ea4\u7684\u533a\u95f4\u4e00\u5b9a\u6ee1\u8db3\u4ee5\u4e0b\u7279\u5f81\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5728 0 \u7684\u5de6\u8fb9 \u5373 r \u2264 l\u2080<\/li>\n\n\n\n<li>\u5728 0 \u7684\u53f3\u8fb9 \u5373 l \u2265 r\u2080<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u4e8e\u6211\u4eec\u5df2\u7ecf\u6309\u7167\u5de6\u7aef\u70b9\u9012\u589e\u6392\u597d\u4e86\u5e8f\uff0c\u56e0\u6b64\u4e0d\u53ef\u80fd\u5b58\u5728 1. \u7684\u60c5\u51b5\uff0c\u56e0\u6b64\u53ea\u5269\u4e0b\u4e86 2. \u8fd9\u79cd\u53ef\u80fd\uff0c\u4e5f\u5c31\u662f\u9009\u62e9\u4e86\u533a\u95f4 0 \u540e\uff0c\u5269\u4e0b\u7684\u53ef\u9009\u533a\u95f4\u4e00\u5b9a\u662fl \u2265 r\u2080\u7684\uff0c\u6211\u4eec\u5c06\u8fd9\u4e2a\u5b50\u96c6\u79f0\u4e4b\u4e3a<math data-latex=\"S_0\\ =\\ \\left\\{seg_i|r_0\\ \\leq\\ l_i\\right\\}\"><semantics><mrow><msub><mi>S<\/mi><mn>0<\/mn><\/msub><mtext>&nbsp;<\/mtext><mo>=<\/mo><mtext>&nbsp;<\/mtext><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mi>s<\/mi><mi>e<\/mi><msub><mi>g<\/mi><mi>i<\/mi><\/msub><mi>|<\/mi><msub><mi>r<\/mi><mn>0<\/mn><\/msub><mtext>&nbsp;<\/mtext><mo>\u2264<\/mo><mtext>&nbsp;<\/mtext><msub><mi>l<\/mi><mi>i<\/mi><\/msub><mo fence=\"true\" form=\"postfix\">}<\/mo><\/mrow><\/mrow><annotation encoding=\"application\/x-tex\">S_0\\ =\\ \\left\\{seg_i|r_0\\ \\leq\\ l_i\\right\\}<\/annotation><\/semantics><\/math>\uff0c\u800c\u9009\u533a\u95f41\u65f6\uff0c\u5bf9\u5e94\u7684\u96c6\u5408\u5c31\u662f<math data-latex=\"S_1\\ =\\ \\left\\{seg_i|r_1\\ \\leq\\ l_i\\right\\}\"><semantics><mrow><msub><mi>S<\/mi><mn>1<\/mn><\/msub><mtext>&nbsp;<\/mtext><mo>=<\/mo><mtext>&nbsp;<\/mtext><mrow><mo fence=\"true\" form=\"prefix\">{<\/mo><mi>s<\/mi><mi>e<\/mi><msub><mi>g<\/mi><mi>i<\/mi><\/msub><mi>|<\/mi><msub><mi>r<\/mi><mn>1<\/mn><\/msub><mtext>&nbsp;<\/mtext><mo>\u2264<\/mo><mtext>&nbsp;<\/mtext><msub><mi>l<\/mi><mi>i<\/mi><\/msub><mo fence=\"true\" form=\"postfix\">}<\/mo><\/mrow><\/mrow><annotation encoding=\"application\/x-tex\">S_1\\ =\\ \\left\\{seg_i|r_1\\ \\leq\\ l_i\\right\\}<\/annotation><\/semantics><\/math>\uff0c\u800c\u7531\u4e8e<math data-latex=\"r_0\"><semantics><msub><mi>r<\/mi><mn>0<\/mn><\/msub><annotation encoding=\"application\/x-tex\">r_0<\/annotation><\/semantics><\/math>\u662f\u5c0f\u4e8e\u7b49\u4e8e<math data-latex=\"r_1\"><semantics><msub><mi>r<\/mi><mn>1<\/mn><\/msub><annotation encoding=\"application\/x-tex\">r_1<\/annotation><\/semantics><\/math>\u7684\uff0c\u56e0\u6b64<math data-latex=\"S_0\"><semantics><msub><mi>S<\/mi><mn>0<\/mn><\/msub><annotation encoding=\"application\/x-tex\">S_0<\/annotation><\/semantics><\/math>\u7684\u96c6\u5408\u5fc5\u7136\u5305\u542b<math data-latex=\"S_1\"><semantics><msub><mi>S<\/mi><mn>1<\/mn><\/msub><annotation encoding=\"application\/x-tex\">S_1<\/annotation><\/semantics><\/math>\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c<math data-latex=\"S_0\"><semantics><msub><mi>S<\/mi><mn>0<\/mn><\/msub><annotation encoding=\"application\/x-tex\">S_0<\/annotation><\/semantics><\/math>\u4e5f\u5fc5\u7136\u5305\u542b\u4efb\u610f\u7684<math data-latex=\"S_i\"><semantics><msub><mi>S<\/mi><mi>i<\/mi><\/msub><annotation encoding=\"application\/x-tex\">S_i<\/annotation><\/semantics><\/math>,\u800c\u5f53\u6211\u4eec\u9009\u62e9\u4e00\u4e2a\u533a\u95f4\u540e\uff0c\u5269\u4e0b\u7684\u53ef\u4ee5\u8ba4\u4e3a\u662f\u53e6\u4e00\u4e2a\u540c\u7b49\u89c4\u6a21\u7684\u5b50\u95ee\u9898\uff0c\u56e0\u4e3a<math data-latex=\"S_0\"><semantics><msub><mi>S<\/mi><mn>0<\/mn><\/msub><annotation encoding=\"application\/x-tex\">S_0<\/annotation><\/semantics><\/math>\u5305\u542b\u4e86\u5176\u4ed6\u7684<math data-latex=\"S_i\"><semantics><msub><mi>S<\/mi><mi>i<\/mi><\/msub><annotation encoding=\"application\/x-tex\">S_i<\/annotation><\/semantics><\/math>\uff0c\u56e0\u6b64\u5fc5\u7136\u6709<math data-latex=\"f(S_0)\\geq f(S_i)\"><semantics><mrow><mi>f<\/mi><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msub><mi>S<\/mi><mn>0<\/mn><\/msub><mo form=\"postfix\" stretchy=\"false\">)<\/mo><mo>\u2265<\/mo><mi>f<\/mi><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msub><mi>S<\/mi><mi>i<\/mi><\/msub><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\">f(S_0)\\geq f(S_i)<\/annotation><\/semantics><\/math>\uff0c\u56e0\u6b64\u9009\u62e9\u7b2c\u4e00\u4e2a\u533a\u95f4\u662f\u6700\u4f73\u7b56\u7565<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u518d\u8ba9\u6211\u4eec\u603b\u7ed3\u4e00\u4e0b\u542f\u53d1\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5982\u679c\u9009\u62e9\u4e0e\u987a\u5e8f\u65e0\u5173\uff0c\u53ef\u4ee5\u5c1d\u8bd5sort<\/li>\n\n\n\n<li>\u533a\u95f4\u7684\u6392\u5e8f\u53ef\u4ee5\u7528\u5de6\u7aef\u70b9\u3001\u53f3\u7aef\u70b9\u3001\u4e2d\u70b9\u3001\u957f\u5ea6\u7b49\u6392\u5e8f<\/li>\n\n\n\n<li>\u8d2a\u5fc3\u7684\u7b56\u7565\u662f\u4e0d\u65ad\u5c1d\u8bd5\u51fa\u6765\u7684\uff0c\u4e00\u4e2a\u7b56\u7565\u4e0d\u884c\u5c31\u6362\u53e6\u4e00\u4e2a\uff0c\u8bc1\u660e\u7b56\u7565\u4e0d\u884c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u627e\u4e00\u4e2a\u53cd\u4f8b<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u6c42\u6700\u5927\u96c6\u5408\u7684\u95ee\u9898\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8bc1\u660e\u9009\u62e9A\u540e\uff0c\u5269\u4f59\u9009\u9879\u96c6\u5408S[A]\uff0c\u5305\u542b\u5176\u4ed6\u7684S[i]\uff0c\u5c31\u53ef\u4ee5\u8bc1\u660e\u8d2a\u5fc3\u7684\u6b63\u786e\u6027<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u6211\u4eec\u518d\u56de\u987e\u4e00\u4e0b\u95ee\u9898\u7684\u62bd\u8c61\u6765\u52a0\u6df1\u4e00\u4e0b\u5370\u8c61\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u72b6\u6001\uff1a\u5df2\u9009\u533a\u95f4\u7684\u96c6\u5408<\/li>\n\n\n\n<li>\u521d\u59cb\u72b6\u6001\uff1a\u7a7a\u96c6\u5408<\/li>\n\n\n\n<li>\u76ee\u6807\u72b6\u6001\uff1a\u65e0\u6cd5\u518d\u9009\u62e9<\/li>\n\n\n\n<li>\u6700\u4f18\u65b9\u6848\uff1a\u6700\u5927\u96c6\u5408<\/li>\n\n\n\n<li>\u72b6\u6001\u8f6c\u79fb\uff1a\u9009\u62e9\u4e00\u4e2a\u4e0d\u91cd\u53e0\u7684\u533a\u95f4<\/li>\n\n\n\n<li>\u7b56\u7565\uff1a\u6309\u53f3\u7aef\u70b9\u6392\u5e8f\u540e\uff0c\u4ec5\u6839\u636e\u5df2\u9009\u62e9\u7684\u53f3\u7aef\u70b9\u9009\u62e9\u7b2c\u4e00\u4e2a\u4e0d\u91cd\u53e0\u7684\u533a\u95f4<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u622a\u6b62\u65e5\u671f\u95ee\u9898<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u95ee\u9898\u5982\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u6709 n \u4e2a\u4efb\u52a1\uff0c\u6bcf\u4e2a\u4efb\u52a1\u90fd\u6709\u622a\u6b62\u65f6\u95f4 d[i] \u548c \u6536\u76ca s[i]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a\u4efb\u52a1\u90fd\u9700\u8981 1 \u5929\u65f6\u95f4\u5b8c\u6210<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u95ee\u6700\u591a\u53ef\u4ee5\u62ff\u5230\u591a\u5c11\u6536\u76ca<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u9053\u9898\u4e0e\u987a\u5e8f\u65e0\u5173\uff0c\u6240\u4ee5\u6211\u4eec\u8fd8\u662f\u5148\u5c1d\u8bd5\u4e00\u4e0b\u6392\u5e8f\uff0c\u6700\u76f4\u63a5\u7684\u60f3\u6cd5\u5c31\u662f\u6309\u7167\u6536\u76ca\u4ece\u5927\u5230\u5c0f\u6392\u5e8f\uff0c\u54ea\u4e2a\u6536\u76ca\u9ad8\u5148\u505a\u54ea\u4e2a\u2193<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">\u622a\u6b62\u65e5\u671f<\/th><th class=\"has-text-align-center\" data-align=\"center\">3<\/th><th class=\"has-text-align-center\" data-align=\"center\">3<\/th><th class=\"has-text-align-center\" data-align=\"center\">1<\/th><th class=\"has-text-align-center\" data-align=\"center\">2<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u6536\u76ca<\/td><td class=\"has-text-align-center\" data-align=\"center\">9<\/td><td class=\"has-text-align-center\" data-align=\"center\">8<\/td><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><td class=\"has-text-align-center\" data-align=\"center\">1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u96be\u770b\u51fa\uff0c\u6536\u76ca\u4e3a9\u548c8\u7684\u4efb\u52a1\u5728\u7b2c\u4e09\u5929\u624d\u622a\u6b62\uff0c\u4f46\u6211\u4eec\u5728\u524d\u4e24\u5929\u5c31\u505a\u5b8c\u4e86\uff0c\u6700\u540e\u8fd8\u80fd\u7a7a\u4f59\u4e00\u5929\uff0c\u4f46\u7531\u4e8e\u6536\u76ca\u4e3a2\u548c1\u7684\u4efb\u52a1\u5df2\u7ecf\u622a\u6b62\u4e86\uff0c\u5bfc\u81f4\u6211\u4eec\u6700\u540e\u4e00\u5929\u88ab\u767d\u767d\u6d6a\u8d39\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u5982\u679c\u6309\u7167\u622a\u6b62\u65e5\u671f\u6392\u5e8f\u5462\uff1f<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">\u622a\u6b62\u65e5\u671f<\/th><th class=\"has-text-align-center\" data-align=\"center\">1<\/th><th class=\"has-text-align-center\" data-align=\"center\">2<\/th><th class=\"has-text-align-center\" data-align=\"center\">3<\/th><th class=\"has-text-align-center\" data-align=\"center\">3<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u6536\u76ca<\/td><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><td class=\"has-text-align-center\" data-align=\"center\">1<\/td><td class=\"has-text-align-center\" data-align=\"center\">9<\/td><td class=\"has-text-align-center\" data-align=\"center\">8<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6309\u7167\u65f6\u95f4\u987a\u5e8f\u505a\uff0c\u5219\u53ef\u80fd\u5bfc\u81f4\u524d\u671f\u7684\u65f6\u95f4\u4f1a\u6d6a\u8d39\u5728\u4f4e\u6536\u76ca\u7684\u4efb\u52a1\u4e0a\uff0c\u5bfc\u81f4\u9ad8\u6536\u76ca\u7684\u4efb\u52a1\u6ca1\u65f6\u95f4\u505a\uff0c\u663e\u7136\u4e5f\u4e0d\u662f\u6700\u4f18\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u65e2\u7136\u5e38\u89c4\u601d\u8def\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u90a3\u6211\u4eec\u5c31\u5c1d\u8bd5\u53cd\u5411\u601d\u8003\uff0c\u5148\u786e\u5b9a\u6700\u540e\u4e00\u5929\u505a\u4ec0\u4e48\uff0c\u518d\u786e\u5b9a\u5012\u6570\u7b2c\u4e8c\u5929\u505a\u4ec0\u4e48\uff0c\u4e00\u76f4\u5012\u63a8\u5230\u7b2c\u4e00\u5929\uff0c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\uff0c\u6211\u4eec\u6700\u540e\u4e00\u5929\u8981\u505a\u7684\u80af\u5b9a\u662f\u8fd8\u5728\u622a\u6b62\u65f6\u95f4\u91cc\u4e14\u6536\u76ca\u6700\u5927\u7684<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th> <\/th><th> <\/th><th>9<\/th><\/tr><\/thead><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5012\u6570\u7b2c\u4e8c\u5929\u5219\u505a\u5728\u622a\u6b62\u65f6\u95f4\u91cc\u4e14\u6536\u76ca\u5012\u6570\u7b2c\u4e8c\u5927\u7684<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th> <\/th><th>8<\/th><th>9<\/th><\/tr><\/thead><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5012\u6570\u7b2c\u4e09\u5929\u5219\u505a\u5728\u622a\u6b62\u65f6\u95f4\u91cc\u4e14\u6536\u76ca\u5012\u6570\u7b2c\u4e09\u5927\u7684<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>2<\/th><th>8<\/th><th>9<\/th><\/tr><\/thead><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u603b\u7ed3\u4e00\u4e0b\uff1a\u8fd9\u4e2a\u95ee\u9898\u7ed9\u6211\u4eec\u7684\u542f\u53d1\u662f\uff0c\u5f53\u4e00\u9053\u9898\u6b63\u5e38\u601d\u8003\u6ca1\u6709\u601d\u8def\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u4e00\u4e0b<strong>\u9006\u5411\u601d\u7ef4<\/strong>\uff0c\u6211\u4eec\u8981\u5bf9\u9006\u5411\u601d\u7ef4<strong>\u795b\u9b45<\/strong>\uff0c\u5f53\u4f5c\u4e00\u79cd\u5e38\u89c4\u7684\u89e3\u9898\u6280\u5de7\uff0c\u4e0d\u8fc7\u662f\u4f60\u4f17\u591a\u5c1d\u8bd5\u4e2d<strong>\u666e\u666e\u901a\u901a\u7684\u4e00\u79cd<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u6211\u4eec\u518d\u62bd\u8c61\u4e00\u4e0b\u8fd9\u9053\u9898\u7684\u6a21\u578b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u72b6\u6001\uff1a\u7b2c i \u5929<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u521d\u59cb\u72b6\u6001\uff1a\u6700\u540e\u4e00\u5929<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u6807\u72b6\u6001\uff1a\u7b2c\u4e00\u5929<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u4f18\u65b9\u6848\uff1a\u6700\u5927\u6536\u76ca<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u72b6\u6001\u8f6c\u79fb\uff1a\u9009\u62e9\u5728\u622a\u81f3\u65e5\u671f\u5185\u7684\u4efb\u52a1<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b56\u7565\uff1a<strong>\u4ec5\u6839\u636e<\/strong>\u5f53\u524d\u65e5\u671f\uff0c\u9009\u6536\u76ca\u6700\u5927\u7684<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\">n\u4e2a\u6709\u5e8f\u6570\u7ec4\u5408\u5e76<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ed9\u4f60 n \u4e2a\u4ece\u5c0f\u5230\u5927\u7684\u6570\u7ec4\uff0c\u628a\u5b83\u4eec\u90fd\u5408\u5e76\u6210\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\uff0c\u5408\u5e76\u5b8c\u7684\u65b0\u6570\u7ec4\u7684\u89c4\u5219\u662fa[0] &lt;= a[1] &lt;= a[2] &lt;= a[3] &lt;= &#8230; &lt;= a[n-1]\u3002<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mtable columnalign=\"center center center\"><mtr><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mn>1<\/mn><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mn>8<\/mn><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mn>9<\/mn><\/mtd><\/mtr><mtr><mtd style=\"border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mn>3<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mn>4<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mn>7<\/mn><\/mtd><\/mtr><mtr><mtd style=\"border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mn>2<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mn>5<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mn>6<\/mn><\/mtd><\/mtr><\/mtable><annotation encoding=\"application\/x-tex\"> \\begin{array}{|c|c|c|} \\hline 1&amp;8&amp;9\\\\ \\hline 3&amp;4&amp;7\\\\ \\hline 2&amp;5&amp;6\\\\ \\hline \\end{array}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u800c\u8fd9 n \u4e2a\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u662f\u5404\u81ea\u6570\u7ec4\u6700\u5c0f\u7684\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u8fd9\u4e9b\u7b2c\u4e00\u4e2a\u5143\u7d20\u4e2d\u627e\u5230\u4e00\u4e2a\u6700\u5c0f\u7684\uff0c\u81ea\u7136\u5c31\u662f\u65b0\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mtable columnalign=\"center center center\"><mtr><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mtext>&nbsp;<\/mtext><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mn>8<\/mn><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mn>9<\/mn><\/mtd><\/mtr><mtr><mtd style=\"border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mn>3<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mn>4<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mn>7<\/mn><\/mtd><\/mtr><mtr><mtd style=\"border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mn>2<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mn>5<\/mn><\/mtd><mtd style=\"border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mn>6<\/mn><\/mtd><\/mtr><\/mtable><annotation encoding=\"application\/x-tex\">\\begin{array}{|c|c|c|}\n\t\\hline \\ &amp;8&amp;9\\\\\n\t\\hline 3&amp;4&amp;7\\\\\n\t\\hline 2&amp;5&amp;6\\\\\n\t\\hline\n\\end{array}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mtable columnalign=\"center center center center center center center center center\"><mtr><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:0pt;padding-right:5.9776pt;border-left:0.06em solid ;border-right:0.06em solid;\"><mn>1<\/mn><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:5.9776pt;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><mtd style=\"border-top:0.06em solid;border-bottom:0.06em solid;padding-left:5.9776pt;padding-right:0.4em;border-right:0.06em solid;\"><mrow><mtext>&nbsp;<\/mtext><mtext>&nbsp;<\/mtext><\/mrow><\/mtd><\/mtr><\/mtable><annotation encoding=\"application\/x-tex\">\\begin{array}{|c|c|c|c|c|c|c|c|c|}\n\t\\hline 1&amp;\\ \\ &amp;\\ \\ &amp;\\ \\ &amp;\\ \\ &amp;\\ \\ &amp;\\ \\ &amp;\\ \\ &amp;\\ \\ \\\\\n\t\\hline\n\\end{array}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8d2a\u5fc3\u7684\u7b56\u7565\u662f\u6709\u4e86\uff0c\u4f46\u8fd9\u9053\u9898\u8003\u5bdf\u7684\u662f\u5982\u4f55\u7f16\u5199\u7a0b\u5e8f\uff0c\u5982\u679c\u6211\u4eec\u6bcf\u6b21\u90fd\u627e\u6700\u5c0f\u7684\u6570\u5b57\u628a\u5b83\u5220\u9664\uff0c\u90a3\u590d\u6742\u5ea6\u5c31\u592a\u5927\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<strong>\u4f18\u5148\u961f\u5217<\/strong>\u8fdb\u884c\u4f18\u5316\uff0c\u5728\u521d\u59cb\u65f6\u5148\u5c06\u5143\u7d20\u653e\u5165\u4f18\u5148\u961f\u5217\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(3, 1, 0)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(2, 2, 0)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1, 0, 0)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\u8bb0\u5f55\u7684\u662f(\u6570\u5b57\uff0c\u7b2c\u51e0\u4e2a\u6570\u7ec4\uff0c\u7b2c\u51e0\u4e2a\u5143\u7d20)\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ea\u9700\u8981\u6bcf\u6b21\u4ece\u4f18\u5148\u961f\u5217\u4e2d\u83b7\u53d6\u6700\u5c0f\u7684\u5143\u7d20\uff0c\u7136\u540e\u6839\u636e\u540e\u4e24\u4e2a\u53c2\u6570\uff0c\u5c06\u65b0\u7684\u5143\u7d20\u52a0\u5165\u4f18\u5148\u961f\u5217\u4e2d\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u76f4\u5230\u539f\u6570\u7ec4\u4e3a\u7a7a\uff0c\u7531\u4e8e\u6211\u4eec\u6bcf\u6b21\u83b7\u53d6\u7684\u6570\u636e\u90fd\u662f\u6700\u5c0f\u7684\uff0c\u6240\u4ee5\u6700\u7ec8\u7684\u987a\u5e8f\u4e00\u5b9a\u662f\u6709\u5e8f\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u9053\u9898\u7ed9\u6211\u4eec\u7684\u542f\u53d1\u662f\uff0c\u4f18\u5148\u961f\u5217\u662f\u8d2a\u5fc3\u7684\u6700\u4f73\u642d\u6863\uff0c\u56e0\u4e3a\u8d2a\u5fc3\u5f80\u5f80\u662f\u4e00\u79cd&#8221;<strong>\u6781\u7aef<\/strong>&#8220;\u7684\u601d\u60f3\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u53d6\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\uff0c\u800c\u4f18\u5148\u961f\u5217\u6070\u597d\u53c8\u662f\u5185\u90e8\u6709\u5e8f\u7684\uff0c\u56e0\u6b64\u5728\u505a\u8d2a\u5fc3\u95ee\u9898\u65f6\uff0c\u6211\u4eec\u5f80\u5f80\u4f1a\u642d\u914d\u4f18\u5148\u961f\u5217\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.cnblogs.com\/Archger\/p\/8451657.html\">C++\u4f18\u5148\u961f\u5217\u8bb2\u89e3<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\u603b\u7ed3\u4e00\u4e0b\u62bd\u8c61\u6a21\u578b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u72b6\u6001\uff1a\u4f18\u5148\u961f\u5217<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u521d\u59cb\u72b6\u6001\uff1a\u7b2c\u4e00\u5217\u653e\u5165\u4f18\u5148\u961f\u5217<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u6807\u72b6\u6001\uff1a\u4f18\u5148\u961f\u5217\u4e3a\u7a7a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u4f18\u65b9\u6848\uff1a\u65b0\u6570\u7ec4\u6709\u5e8f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u72b6\u6001\u8f6c\u79fb\uff1a\u9009\u53d6\u4e00\u4e2a\u5143\u7d20<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b56\u7565\uff1a<strong>\u4ec5\u6839\u636e<\/strong>\u4f18\u5148\u961f\u5217\uff0c\u9009\u62e9\u6700\u5c0f\u7684<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u7ec3\u4e60\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u518d\u56de\u987e\u4e00\u4e0b\u8d2a\u5fc3\u95ee\u9898\u7684\u89e3\u9898\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5236\u5b9a\u67d0\u4e2a\u8d2a\u5fc3\u7684\u7b56\u7565<\/li>\n\n\n\n<li>\u8bc1\u660e\u8fd9\u4e2a\u7b56\u7565\u7684\u6b63\u786e\u6027<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8bc1\u660e\u7b56\u7565\u6b63\u786e\u6027\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u4e4f\u6709\u4e00\u4e9b\u975e\u5e38\u7b80\u5355\u4e00\u773c\u5c31\u80fd\u770b\u51fa\u6765\u7684\u8bc1\u660e\uff0c\u4e5f\u6709\u7684\u9700\u8981\u590d\u6742\u7684\u6570\u5b66\u63a8\u5bfc\u624d\u80fd\u8bc1\u660e\uff0c\u8fd9\u4e5f\u662f\u65b0\u624b\u8ba4\u4e3a\u8d2a\u5fc3\u5341\u5206\u7b80\u5355\uff0c\u800c\u9ad8\u624b\u624d\u660e\u767d\uff0c\u8d2a\u5fc3\u96be\u8d77\u6765\u4f1a\u6bd4\u5176\u4ed6\u7b97\u6cd5\u96be\u5f97\u591a\u7684\u539f\u56e0\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u505a\u9898\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u8981\u6ce8\u91cd\u8fd9\u4e9b\u7ed3\u8bba\u7684\u63a8\u5bfc\uff0c\u5982\u679c\u6ca1\u601d\u8def\u5c31\u7acb\u9a6c\u770b\u9898\u89e3\uff0c\u8fc7\u4e00\u6bb5\u65f6\u95f4\u540e\u8fd8\u662f\u4f1a\u5fd8\uff0c\u90a3\u6837\u5f97\u5230\u7684\u63d0\u9ad8\u51e0\u4e4e\u662f\u5fae\u4e4e\u5176\u5fae\uff0c\u6bd4\u8d5b\u4e5f\u51e0\u4e4e\u4e0d\u53ef\u80fd\u51fa\u73b0\u540c\u4e00\u9053\u9898\u76ee\uff0c\u5e0c\u671b\u5927\u5bb6\u5728\u601d\u8003\u7684\u8fc7\u7a0b\u4e2d\uff0c\u80fd\u6536\u83b7\u601d\u7ef4\u4e0a\u7684\u63d0\u5347\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd8a\u8d2a\u5fc3\u7ec3\u4e60<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/leetcode.cn\/problems\/non-overlapping-intervals\/description\/\">-11.LeetCode 435.\u65e0\u91cd\u53e0\u533a\u95f4<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u9898\u5b9e\u9645\u4e0a\u5c31\u662f\u4e0a\u8ff0\u7684<strong>\u96c6\u5408\u9009\u62e9\u95ee\u9898<\/strong>\uff0c\u6240\u4ee5\u518d\u6b64\u5c31\u4e0d\u505a\u8d58\u8ff0\u4e86\uff0c\u4e3b\u8981\u770b\u4ee3\u7801\u7684\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C++11\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Solution {<br>public:<br> &nbsp; &nbsp;int eraseOverlapIntervals(vector&lt;vector&lt;int&gt;&gt;&amp; intervals) {<br> &nbsp; &nbsp; &nbsp; &nbsp;\/\/\u53f3\u7aef\u70b9\u4ece\u5c0f\u5230\u5927\u6392\u5e8f<br> &nbsp; &nbsp; &nbsp; &nbsp;sort(intervals.begin(),intervals.end(),[](const vector&lt;int&gt; &amp;a, const vector&lt;int&gt; &amp;b){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return a[1] &lt; b[1];<br> &nbsp; &nbsp; &nbsp;  });<br> &nbsp; &nbsp; &nbsp; &nbsp;int ans = 0;    \/\/\u8bb0\u5f55\u80fd\u9009\u62e9\u591a\u5c11\u4e2a\u533a\u95f4<br> &nbsp; &nbsp; &nbsp; &nbsp;int right = -1e5;   \/\/\u8bb0\u5f55\u4e0a\u4e00\u4e2a\u96c6\u5408\u7684\u53f3\u7aef\u70b9<br> &nbsp; &nbsp; &nbsp; &nbsp;for(auto &amp;interval : intervals){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(interval[0] &gt;= right){   \/\/\u5982\u679c\u96c6\u5408\u5de6\u7aef\u70b9 &gt;= \u5de6\u4fa7\u96c6\u5408\u7684\u53f3\u7aef\u70b9\uff0c\u5219\u4ee3\u8868\u96c6\u5408\u4e4b\u95f4\u6ca1\u6709\u91cd\u53e0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;right = interval[1];    \/\/\u66f4\u65b0\u53f3\u7aef\u70b9<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ans++;          \/\/\u7b54\u6848\u589e\u52a0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return intervals.size() - ans;      \/\/\u603b\u533a\u95f4\u6570 - \u9009\u62e9\u7684\u533a\u95f4 \u5c31\u662f\u7b54\u6848<br> &nbsp;  }<br>};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">sort\u51fd\u6570\u7528\u4e8e\u5c06\u96c6\u5408\u6309\u7167\u53f3\u7aef\u70b9\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff0csort\u51fd\u6570\u4f20\u5165\u4e09\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u4e3a(\u8d77\u59cb\u4f4d\u7f6e\uff0c\u7ec8\u6b62\u4f4d\u7f6e\uff0c\u6392\u5e8f\u89c4\u5219)\uff0c\u5176\u4e2d\u6392\u5e8f\u89c4\u5219\u53ef\u4ee5\u4e0d\u5199\uff0c\u7f3a\u7701\u4e3aless&lt;T&gt;()\u9012\u589e\u6392\u5e8f\u3002\u5bf9\u4e8eC++20\u53ca\u4ee5\u4e0a\u7248\u672c\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Solution {<br>public:<br> &nbsp; &nbsp;int eraseOverlapIntervals(vector&lt;vector&lt;int&gt;&gt;&amp; intervals) {<br> &nbsp; &nbsp; &nbsp; &nbsp;\/\/\u53f3\u7aef\u70b9\u4ece\u5c0f\u5230\u5927\u6392\u5e8f<br> &nbsp; &nbsp; &nbsp; &nbsp;ranges::sort(intervals,[](auto &amp;a, auto &amp;b){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return a[1] &lt; b[1];<br> &nbsp; &nbsp; &nbsp;  });<br> &nbsp; &nbsp; &nbsp; &nbsp;int ans = 0;    \/\/\u8bb0\u5f55\u80fd\u9009\u62e9\u591a\u5c11\u4e2a\u533a\u95f4<br> &nbsp; &nbsp; &nbsp; &nbsp;int right = -1e5;   \/\/\u8bb0\u5f55\u4e0a\u4e00\u4e2a\u96c6\u5408\u7684\u53f3\u7aef\u70b9<br> &nbsp; &nbsp; &nbsp; &nbsp;for(auto &amp;interval : intervals){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(interval[0] &gt;= right){   \/\/\u5982\u679c\u96c6\u5408\u5de6\u7aef\u70b9 &gt;= \u5de6\u4fa7\u96c6\u5408\u7684\u53f3\u7aef\u70b9\uff0c\u5219\u4ee3\u8868\u96c6\u5408\u4e4b\u95f4\u6ca1\u6709\u91cd\u53e0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;right = interval[1];    \/\/\u66f4\u65b0\u53f3\u7aef\u70b9<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ans++;          \/\/\u7b54\u6848\u589e\u52a0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return intervals.size() - ans;      \/\/\u603b\u533a\u95f4\u6570 - \u9009\u62e9\u7684\u533a\u95f4 \u5c31\u662f\u7b54\u6848<br> &nbsp;  }<br>};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>lambda \u7684\u53c2\u6570\u7528 auto<\/strong>\u5728C++14\u5f15\u5165\uff0c<strong>ranges::sort<\/strong>\u662f\u5728 C++20 \u5f15\u5165\u7684\u8303\u56f4\u6392\u5e8f\uff0c\u7b49\u4ef7\u4e8e\u4f20\u7edf sort(intervals.begin(), intervals.end(), &#8230;)\uff0c\u5199\u6cd5\u66f4\u7b80\u6d01\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b66\u4e60\u4f4e\u7248\u672c\u7684\u8bed\u6cd5\u662f\u4e3a\u4e86\u5de9\u56fa\u57fa\u7840\u77e5\u8bc6\uff0c\u540c\u65f6\u4e5f\u66f4\u597d\u7684\u9002\u5e94\u7b97\u6cd5\u7ade\u8d5b\uff0c\u5b66\u4e60\u9ad8\u7248\u672c\u7684\u8bed\u6cd5\u662f\u4e3a\u4e86\u8ba9\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u66f4\u597d\uff0c\u5199\u4ee3\u7801\u65f6\u66f4\u52a0\u4e1d\u6ed1\uff0c\u5728\u540e\u9762\u7684\u7ec3\u4e60\u4e2d\uff0c\u6211\u4e5f\u4f1a\u5c3d\u91cf\u52a0\u5165\u4e0d\u540c\u7248\u672c\u7684\u8bed\u6cd5\u6765\u4f9b\u5927\u5bb6\u6bd4\u8f83\u5b66\u4e60\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/leetcode.cn\/problems\/merge-k-sorted-lists\/description\/\">-12.LeetCode 23.\u5408\u5e76 K \u4e2a\u5347\u5e8f\u94fe\u8868<\/a><\/h4>\n\n\n\n<h2 class=\"wp-block-heading\">Part 3\uff1a\u5206\u6cbb<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6316\u4e00\u4e2a\u5751\u5728\u8fd9\u91cc\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Part 4\uff1a\u56de\u6eaf<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd5\u56de\u6eaf<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd8a\u56de\u6eaf\u7ec3\u4e60<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/leetcode.cn\/problems\/permutations\/description\/\">-16.LeetCode 46.\u5168\u6392\u5217<\/a><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u672c\u9898\uff0c\u6211\u4eec\u4e0d\u96be\u770b\u51fa\u4ee5\u4e0b\u6027\u8d28\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5168\u6392\u5217\u4e2d\u7684\u6240\u6709\u53ef\u80fd\u6392\u5217\uff0c\u5176\u5185\u90e8\u5143\u7d20\u6570\u91cf\u5fc5\u5b9a\u548c\u539f\u6570\u7ec4\u76f8\u540c<\/li>\n\n\n\n<li>ans\u7684\u7c7b\u578b\u662fvector&lt;vector&lt;int>>\uff0cans\u5185\u90e8\u5143\u7d20perm\u7684\u7c7b\u578b\u4e3avector&lt;int><\/li>\n\n\n\n<li>\u6700\u540e\u8fd4\u56de\u7684ans\uff0c\u5185\u90e8\u5143\u7d20\u4e2a\u6570\u662f(nums.size())!\uff0c\u4e5f\u5c31\u662f\u539f\u6570\u7ec4nums\u5143\u7d20\u4e2a\u6570\u7684\u9636\u4e58<\/li>\n\n\n\n<li>\u663e\u7136\u6211\u4eec\u9700\u8981\u904d\u5386nums\u4e2d\u7684\u6570\u5b57\u6765\u5224\u65ad\u5176\u662f\u5426\u53ef\u4ee5\u653e\u8fdbperm\u4e2d,\u4f46\u4f7f\u7528\u8fc7\u7684\u6570\u5b57\u5fc5\u5b9a\u4e0d\u80fd\u518d\u6b21\u653e\u8fdbperm\u4e2d\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8fdb\u884c\u526a\u679d\uff0c\u901a\u8fc7\u8f85\u52a9\u72b6\u6001\u2014\u2014\u5f00\u8f9f\u4e00\u4e2aused[]\u6570\u7ec4\uff0c\u5224\u65ad\u6bcf\u4e2a\u5143\u7d20\u662f\u5426\u88ab\u4f7f\u7528\u8fc7\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u6548\u7387<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u6211\u4eec\u76f4\u63a5\u770b\u770b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Solution {<br>public:<br> &nbsp; &nbsp;vector&lt;vector&lt;int&gt;&gt; permute(vector&lt;int&gt;&amp; nums) {<br> &nbsp; &nbsp; &nbsp; &nbsp;int n = nums.size();<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;vector&lt;int&gt;&gt; ans;    \/\/\u7b54\u6848\u6570\u7ec4<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;int&gt; perm;           \/\/ans\u4e2d\u7684\u5143\u7d20<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;bool&gt; used(n);       \/\/\u8f85\u52a9\u72b6\u6001<br> &nbsp; &nbsp; &nbsp; &nbsp;traceback(perm,n,ans,nums,used);<br> &nbsp; &nbsp; &nbsp; &nbsp;return ans;<br> &nbsp;  }<br>    \/*\u2193\u6838\u5fc3\u51fd\u6570\u2193*\/<br> &nbsp; &nbsp;void traceback(vector&lt;int&gt; &amp;perm,int &amp;n,vector&lt;vector&lt;int&gt;&gt; &amp;ans,vector&lt;int&gt; &amp;nums,vector&lt;bool&gt; &amp;used){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(perm.size() == n){   \/\/\u901a\u8fc7\u6027\u8d281.\u6613\u77e5<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ans.push_back(perm);    \/\/\u538b\u5165\u7b54\u6848\u6570\u7ec4\u4e2d<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;     \/\/\u56de\u5230\u4e0a\u4e00\u4e2a\u9009\u62e9\u5206\u652f<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0; i &lt; n; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(used[i]) continue;   \/\/\u5982\u679c\u8fd9\u4e2a\u6570\u5b57\u88ab\u9009\u62e9\u8fc7\uff0c\u5219\u8df3\u8fc7\u5b83<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;perm.push_back(nums[i]);    \/\/\u5426\u5219\u52a0\u5165perm\u4e2d<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;used[i] = true;         \/\/\u66f4\u65b0\u8f85\u52a9\u72b6\u6001<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;traceback(perm,n,ans,nums,used);    \/\/\u9012\u5f52\u8c03\u7528<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;used[i] = false;        \/\/\u56de\u6eaf\u66f4\u65b0\u72b6\u6001<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;perm.pop_back();        \/\/\u56de\u6eaf\u66f4\u65b0\u72b6\u6001<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br>};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">C++11\u4e0d\u652f\u6301 <strong>lambda \u7684\u53c2\u6570\u7528 auto<\/strong>\uff0c\u4e5f\u4e0d\u652f\u6301<strong>\u201c\u901a\u7528 lambda \u9012\u5f52\u201d<\/strong> \u8fd9\u79cd\u8bed\u6cd5\uff0c\u4f46\u5bf9\u4e8eC++14\u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Solution {<br>public:<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;vector&lt;vector&lt;int&gt;&gt; permute(vector&lt;int&gt;&amp; nums) {<br> &nbsp; &nbsp; &nbsp; &nbsp;int n = nums.size();<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;vector&lt;int&gt;&gt; ans;<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;int&gt; perm;<br> &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;bool&gt; used(n);<br> &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp;auto traceback = [&amp;](auto &amp;&amp; self){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(perm.size() == n){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ans.push_back(perm);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0; i &lt; n; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(used[i]) continue;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;perm.push_back(nums[i]);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;used[i] = true;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self(self);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;used[i] = false;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;perm.pop_back();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;  };<br> &nbsp; &nbsp; &nbsp; &nbsp;traceback(traceback);<br> &nbsp; &nbsp; &nbsp; &nbsp;return ans;<br> &nbsp;  }<br>};<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6742\u8c08<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.\u6570\u8bba\u2014\u5173\u4e8e\u6570\u6839<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u6839\u53c8\u79f0\u6570\u5b57\u6839(Digital root)\uff0c\u662f\u81ea\u7136\u6570\u7684\u4e00\u79cd\u6027\u8d28\uff0c\u6bcf\u4e2a\u81ea\u7136\u6570\u90fd\u6709\u4e00\u4e2a\u6570\u6839\u3002\u5bf9\u4e8e\u7ed9\u5b9a\u7684\u81ea\u7136\u6570\uff0c\u53cd\u590d\u5c06\u5404\u4e2a\u4f4d\u4e0a\u7684\u6570\u5b57\u76f8\u52a0\uff0c\u76f4\u5230\u7ed3\u679c\u4e3a\u4e00\u4f4d\u6570\uff0c\u5219\u8be5\u4e00\u4f4d\u6570\u5373\u4e3a\u539f\u81ea\u7136\u6570\u7684\u6570\u6839\u3002\u5982369\u7684\u6811\u6839\u8ba1\u7b97\u65b9\u5f0f\u5982\u4e0b\uff1a3+6+9=18\uff0c1+8=9\uff0c\u5373369\u7684\u6811\u6839\u4e3a9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u603b\u7ed3\u89c4\u5f8b\uff0c\u5047\u8bbe\u81ea\u7136\u6570num\u7684\u5341\u8fdb\u5236\u8868\u793a\u6709n\u4f4d\uff0c\u4ece\u6700\u4f4e\u4f4d\u5230\u6700\u9ad8\u4f4d\u4f9d\u6b21\u662fa\u2080\u5230a\u2099\u208b\u2081\uff0c\u5219num\u53ef\u4ee5\u5199\u6210\u5982\u4e0b\u5f62\u5f0f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><\/math><\/div>\n\n\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mtable displaystyle=\"true\" columnalign=\"right left\" class=\"tml-jot\"><mtr><mtd class=\"tml-right\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mi>n<\/mi><mi>u<\/mi><mi>m<\/mi><\/mrow><\/mtd><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>=<\/mo><mrow><munderover><mo movablelimits=\"false\">\u2211<\/mo><mrow><mi>i<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><mrow><mi>n<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/munderover><\/mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mo>\u00d7<\/mo><msup><mn>10<\/mn><mi>i<\/mi><\/msup><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-right\" style=\"padding-left:0em;padding-right:0em;\"><mrow><\/mrow><\/mtd><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>=<\/mo><mrow><munderover><mo movablelimits=\"false\">\u2211<\/mo><mrow><mi>i<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><mrow><mi>n<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/munderover><\/mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mo>\u00d7<\/mo><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mn>10<\/mn><mi>i<\/mi><\/msup><mo>\u2212<\/mo><mn>1<\/mn><mo>+<\/mo><mn>1<\/mn><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><\/mtd><\/mtr><mtr><mtd class=\"tml-right\" style=\"padding-left:0em;padding-right:0em;\"><mrow><\/mrow><\/mtd><mtd class=\"tml-left\" style=\"padding-left:0em;padding-right:0em;\"><mrow><mo>=<\/mo><mrow><munderover><mo movablelimits=\"false\">\u2211<\/mo><mrow><mi>i<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><mrow><mi>n<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/munderover><\/mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><mo>\u00d7<\/mo><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mn>10<\/mn><mi>i<\/mi><\/msup><mo>\u2212<\/mo><mn>1<\/mn><mo form=\"postfix\" stretchy=\"false\">)<\/mo><mo>+<\/mo><mrow><munderover><mo movablelimits=\"false\">\u2211<\/mo><mrow><mi>i<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><mrow><mi>n<\/mi><mo>\u2212<\/mo><mn>1<\/mn><\/mrow><\/munderover><\/mrow><msub><mi>a<\/mi><mi>i<\/mi><\/msub><\/mrow><\/mtd><\/mtr><\/mtable><annotation encoding=\"application\/x-tex\">\\begin{aligned}\nnum &amp;= \\sum_{i=0}^{n-1} a_i \\times 10^i \\\\\n    &amp;= \\sum_{i=0}^{n-1} a_i \\times (10^i &#8211; 1 + 1) \\\\\n    &amp;= \\sum_{i=0}^{n-1} a_i \\times (10^i &#8211; 1) + \\sum_{i=0}^{n-1} a_i\n\\end{aligned}\n<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u663e\u7136\uff0c\u5bf9\u4e8e\u4efb\u610f\u975e\u8d1f\u6574\u6570 i\uff0c10\u2071 &#8211; 1 = 0\u90fd\u662f 9 \u7684\u500d\u6570\u3002\u7531\u6b64\u53ef\u5f97 num \u4e0e\u5176\u5404\u4f4d\u76f8\u52a0\u7684\u7ed3\u679c\u6a21 9 \u540c\u4f59\uff0cnum\u4e0e\u5176\u6570\u6839\u6a21 9 \u4e5f\u540c\u4f59\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba8\u8bba num \u60c5\u51b5<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>num \u4e0d\u662f 9 \u7684\u500d\u6570\u65f6\uff0c\u5176\u6570\u6839\u5373\u4e3a num \u9664\u4ee5 9 \u7684\u4f59\u6570\u3002<\/li>\n\n\n\n<li>num \u662f 9 \u7684\u500d\u6570\u65f6\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c num = 0\uff0c\u5176\u6570\u6839\u662f0\uff1b<\/li>\n\n\n\n<li>\u5982\u679c num > 0\uff0c\u5219\u5404\u4f4d\u76f8\u52a0\u7684\u7ed3\u679c\u5927\u4e8e0\uff0c\u5176\u6570\u6839\u4e5f\u5927\u4e8e0\uff0c\u56e0\u6b64\u5176\u6570\u6839\u662f 9\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7ed3\u8bba\uff1anum\u7684\u6570\u6839 = ( num &#8211; 1 ) % 9 + 1;<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.\u4e00\u822c\u5b9a\u957f\u6ed1\u52a8\u7a97\u53e3\u677f\u5b50<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4e00\u6570\u7ec4 arr \u4e2d\u5bf9\u4e00\u5b9a\u957f\u4e3a k \u7684\u533a\u95f4\u8fdb\u884c\u5904\u7406\uff0c\u4f7f\u7528\u6ed1\u52a8\u7a97\u53e3\u6a21\u578b\uff0c\u6ce8\u610f\u8fb9\u754c\u5904\u7406\u95ee\u9898\uff0c\u4ee5\u53ca\u5de6\u53f3\u8fb9\u754c\u7684\u66f4\u65b0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Solution {<br>public:<br> &nbsp; &nbsp;int title(vector&lt;int&gt;&amp; arr, int k, auto other_Info) {<br> &nbsp; &nbsp; &nbsp; &nbsp;int count = 0;<br> &nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0; i &lt; k; i++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/\u5148\u5bf9 count \u7684 0 ~ (k-1) \u8fd9\u4e2a\u533a\u95f4\u8fdb\u884c\u5904\u7406,<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;int ans = 0;    \/\/\u7b54\u6848\u8ba1\u6570\u5668<br> &nbsp; &nbsp; &nbsp; &nbsp;if(\/*\u6ee1\u8db3\u67d0\u4e2a\u6761\u4ef6*\/) ans++;<br> &nbsp; &nbsp; &nbsp; &nbsp;for(int i = 0, j = k - 1; j &lt; arr.size() - 1; i++, j++){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/\u66f4\u65b0\u5de6\u53f3\u8fb9\u754c<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;count \/* \u5904\u7406 *\/ arr[j + 1];<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;count \/* \u5904\u7406 *\/ arr[i];<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(\/*\u6ee1\u8db3\u67d0\u4e2a\u6761\u4ef6*\/)ans++;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return ans;<br> &nbsp;  }<br>};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.\u535a\u5f08\u8bba\u2014CHOMP-\u975e\u6784\u9020\u6027\u8bc1\u660e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u2014\u2014by Everfades \uff08\u26a0\ufe0f\u5fc5\u8bfb\uff09\u672c\u7b14\u8bb0\u4e3b\u8981\u9488\u5bf9\u4e8e\u8f83\u4e3a\u6838\u5fc3\u7684\u516d\u5927\u7b97\u6cd5(\u4e3b\u89c2\u5411) \u679a\u4e3e\u3001\u8d2a\u5fc3\u3001\u5206\u6cbb\u3001\u56de\u6eaf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10,12,11],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-artical","tag-c","tag-12","tag-11"],"_links":{"self":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":1,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts\/54\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}