{"id":251,"date":"2024-11-23T09:29:29","date_gmt":"2024-11-23T01:29:29","guid":{"rendered":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/%e7%ae%97%e6%b3%95%e7%bb%83%e4%b9%a0%ef%bc%9a%e5%8f%aa%e6%9c%89%e4%b8%a4%e4%b8%aa%e9%94%ae%e7%9a%84%e9%94%ae%e7%9b%98%ef%bc%88%e6%95%b0%e5%ad%a6%e6%b3%95%ef%bc%8c%e5%8a%a8%e6%80%81%e8%a7%84%e5%88%92\/"},"modified":"2024-11-23T09:29:29","modified_gmt":"2024-11-23T01:29:29","slug":"%e7%ae%97%e6%b3%95%e7%bb%83%e4%b9%a0%ef%bc%9a%e5%8f%aa%e6%9c%89%e4%b8%a4%e4%b8%aa%e9%94%ae%e7%9a%84%e9%94%ae%e7%9b%98%ef%bc%88%e6%95%b0%e5%ad%a6%e6%b3%95%ef%bc%8c%e5%8a%a8%e6%80%81%e8%a7%84%e5%88%92","status":"publish","type":"post","link":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/%e7%ae%97%e6%b3%95%e7%bb%83%e4%b9%a0%ef%bc%9a%e5%8f%aa%e6%9c%89%e4%b8%a4%e4%b8%aa%e9%94%ae%e7%9a%84%e9%94%ae%e7%9b%98%ef%bc%88%e6%95%b0%e5%ad%a6%e6%b3%95%ef%bc%8c%e5%8a%a8%e6%80%81%e8%a7%84%e5%88%92\/","title":{"rendered":"\u7b97\u6cd5\u7ec3\u4e60\uff1a\u53ea\u6709\u4e24\u4e2a\u952e\u7684\u952e\u76d8\uff08\u6570\u5b66\u6cd5\uff0c\u52a8\u6001\u89c4\u5212\uff09"},"content":{"rendered":"<h2>\u4e00.\u524d\u8a00<\/h2>\n<p>\u53c8\u5230\u4e86\u8bb0\u5f55\u4ee3\u7801\u7684\u65f6\u5019\u4e86\uff0c\u8fd9\u9053\u9898\u6765\u81eaLeetCode\uff0c\u53ea\u6709\u4e24\u4e2a\u952e\u7684\u952e\u76d8\uff1a<\/p>\n<p>\u6700\u521d\u8bb0\u4e8b\u672c\u4e0a\u53ea\u6709\u4e00\u4e2a\u5b57\u7b26 &#8216;A&#8217; \u3002\u4f60\u6bcf\u6b21\u53ef\u4ee5\u5bf9\u8fd9\u4e2a\u8bb0\u4e8b\u672c\u8fdb\u884c\u4e24\u79cd\u64cd\u4f5c\uff1a<br \/>\nCopy All\uff08\u590d\u5236\u5168\u90e8\uff09\uff1a\u590d\u5236\u8fd9\u4e2a\u8bb0\u4e8b\u672c\u4e2d\u7684\u6240\u6709\u5b57\u7b26\uff08\u4e0d\u5141\u8bb8\u4ec5\u590d\u5236\u90e8\u5206\u5b57\u7b26\uff09\u3002<br \/>\nPaste\uff08\u7c98\u8d34\uff09\uff1a\u7c98\u8d34 \u4e0a\u4e00\u6b21 \u590d\u5236\u7684\u5b57\u7b26\u3002<br \/>\n\u7ed9\u4f60\u4e00\u4e2a\u6570\u5b57 n \uff0c\u4f60\u9700\u8981\u4f7f\u7528\u6700\u5c11\u7684\u64cd\u4f5c\u6b21\u6570\uff0c\u5728\u8bb0\u4e8b\u672c\u4e0a\u8f93\u51fa \u6070\u597d n \u4e2a &#8216;A&#8217; \u3002\u8fd4\u56de\u80fd\u591f\u6253\u5370\u51fa n \u4e2a &#8216;A&#8217; \u7684\u6700\u5c11\u64cd\u4f5c\u6b21\u6570\u3002<\/p>\n<p>\u4e0b\u9762\u7ed9\u51fa\u4e24\u4e2a\u4f8b\u5b50\uff1a<br \/>\n<code>\u793a\u4f8b1\uff1a<\/code><\/p>\n<blockquote>\n<p>\u8f93\u5165\uff1a3<br \/>\n\u8f93\u51fa\uff1a3<br \/>\n\u89e3\u91ca\uff1a<br \/>\n\u6700\u521d, \u53ea\u6709\u4e00\u4e2a\u5b57\u7b26 &#8216;A&#8217;\u3002<br \/>\n\u7b2c 1 \u6b65, \u4f7f\u7528 Copy All \u64cd\u4f5c\u3002<br \/>\n\u7b2c 2 \u6b65, \u4f7f\u7528 Paste \u64cd\u4f5c\u6765\u83b7\u5f97 &#8216;AA&#8217;\u3002<br \/>\n\u7b2c 3 \u6b65, \u4f7f\u7528 Paste \u64cd\u4f5c\u6765\u83b7\u5f97 &#8216;AAA&#8217;\u3002<\/p>\n<\/blockquote>\n<p><code>\u793a\u4f8b2\uff1a<\/code><\/p>\n<blockquote>\n<p>\u8f93\u5165\uff1an = 1<br \/>\n\u8f93\u51fa\uff1a0<\/p>\n<\/blockquote>\n<h2>\u4e8c.\u9898\u89e3<\/h2>\n<p>\u9996\u5148\u8bf4\u8bf4\u7b14\u8005\u5199\u8fd9\u9053\u9898\u7684\u7ecf\u5386\u5427\uff0c\u4e0d\u6015\u5927\u5bb6\u7b11\u8bdd\uff0c\u8fd9\u9053\u9898\u6211\u8db3\u8db3\u5199\u4e863\u5c0f\u65f6&#8230;\u6700\u5f00\u59cb\u770b\u5230\u8fd9\u9053\u9898\u7684\u65f6\u5019\u6211\u60f3\u7684\u662f\u6211\u53ef\u4ee5\u5c06 n \u4ee5\u524d\u7684\u64cd\u4f5c <code>A<\/code> \u7684\u6b21\u6570\u4ee5\u6b21\u6570\u4e3a\u952e\u7528 <code>Hashmap<\/code> \u5b58\u8d77\u6765\uff0c\u7136\u540e\u9047\u5230 <code>n<\/code> \u7684\u65f6\u5019\u76f4\u63a5\u53bb <code>Hashmap<\/code> \u91cc\u9762\u62ff\uff0c\u5f53\u6211\u53bb\u63d0\u4ea4\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u6709\u4e9b\u6d4b\u8bd5\u7528\u4f8b\u662f\u8fc7\u4e0d\u4e86\u7684\uff0c\u6bd4\u82e5\u8bf4741\u3002\u7136\u540e\u6211\u91cd\u65b0\u601d\u8003\uff0c\u53d1\u73b0\u53ef\u4ee5\u7528\u9012\u5f52\uff0c\u4f46\u662f\u7531\u4e8e\u601d\u8003\u6df1\u5ea6\u4e0d\u591f\uff0c\u53c8\u6709\u4e00\u4e9b\u60c5\u51b5\u6ca1\u8003\u8651\u5230\uff0c\u53bb\u63d0\u4ea4\u7684\u53c8\u6570\u6b21\u5931\u8d25&#8230;\u771f\u7684\u607c\u706b\u3002<\/p>\n<p>\u7531\u4e8e\u9012\u5f52\u4ece\u6700\u5f00\u59cb\u5c31\u6ca1\u8003\u8651\u5230\u90a3\u79cd\u60c5\u51b5\uff0c\u56e0\u6b64\u6539\u8d77\u6765\u7279\u522b\u9ebb\u70e6\uff0c\u800c\u8fd9\u4e0d\u5f97\u4e0d\u4f7f\u6211\u91cd\u65b0\u9009\u62e9\u4e00\u6761\u8def\u51fa\u53d1\u3002\u6240\u4ee5\u7531\u6b64\u770b\u6765\u554a\uff0c\u505a\u9898\u4e4b\u524d\u771f\u8981\u9759\u4e0b\u5fc3\u6765\u601d\u8003\uff0c\u601d\u8003\u8303\u56f4\u8981\u5e7f\u4e00\u70b9\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u8bf4\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff0c\u6211\u79f0\u4e4b\u4e3a\u6570\u5b66\u89c4\u5f8b\u6cd5\u3002<\/p>\n<h3>1.\u6570\u5b66\u89c4\u5f8b\u6cd5<\/h3>\n<p>\u5148\u4e3e\u4e00\u4e9b\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre><code>\u5f53\u8f93\u5165\u4e0d\u540c\u7684 n \u65f6\uff0c\u5bf9\u5e94\u8f93\u51fa\u7684\u503c\uff1a\n\n1 = 0\n2 = 1 2 --&gt; 2\u6b21\/\/\u56e0\u4e3a\u9700\u8981\u590d\u5236\u4e00\u6b21\uff0c\u7c98\u8d34\u4e00\u6b21\uff0c\u56e0\u6b64\u662f2\n7 = 1 2 3 4 5 6 7 --&gt; 7\u6b21\/\/ 1 + 1 + 1 + 1 + 1 + 1 + 1 = 7\n12 = 1 2 3 6 12 --&gt; 7\u6b21 \/\/2 + 1 + 2 + 2 = 7\n18 = 1 2 3 6 9 18 --&gt; 8\u6b21 \/\/2 + 1 + 2 + 1 +2 = 8\n25 = 1 2 3 4 5 10 15 20 25 --&gt; 10\u6b21 \/\/2 + 1 + 1 + 2 +1 + 1 + 1 + 1 = 10\n741 = 35\u6b21 --&gt; \u8fd9\u4e2a\u5f85\u4f1a\u8bb2\n<\/code><\/pre>\n<p>\u65e2\u7136\u662f\u6570\u5b66\u65b9\u6cd5\uff0c\u5f53\u7136\u8981\u8fd0\u7528\u5f3a\u5927\u7684\u6570\u5b66\u89c4\u5f8b\uff0c\u6211\u4eec\u4ed4\u7ec6\u89c2\u5bdf\u4e00\u756a\u4f1a\u53d1\u73b0\uff1a\u5982\u679c\u662f\u8d28\u6570\u90a3\u4e48\u5b83\u7684\u6700\u5c0f\u64cd\u4f5c\u6b21\u6570\u5c31\u662f\u5b83\u672c\u8eab\uff0c\u5bf9\u4e8e\u975e\u8d28\u6570\uff0c\u6bd4\u5982\u8bf4 <code>12<\/code> \uff0c\u4e0a\u9762\u5f97\u51fa <code>6<\/code> \u6b21\u7b54\u6848\u7684\u8fc7\u7a0b\u6211\u4eec\u5012\u7740\u770b\u5206\u62103\u4e2a\u7247\u6bb5,12\n<\/p>\n<p>\u9996\u5148\u6765\u770b 12 6 \u5982\u679c\u8981\u6210\u4e3a <code>12<\/code> \u5fc5\u987b\u5148\u5168\u90e8\u590d\u5236\u518d\u7c98\u8d34\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u91cc\u4f1a\u67092\u6b21\u64cd\u4f5c\uff1b\u518d\u770b 6 3 \u5982\u679c\u8981\u6210\u4e3a <code>6<\/code> \u4e5f\u5fc5\u987b\u5148\u5168\u90e8\u590d\u5236\u518d\u7c98\u8d34\uff0c\u4e5f\u4f1a\u67092\u6b21\u64cd\u4f5c\uff1b\u6700\u540e\u770b 3 1 \u5982\u679c\u8981\u6210\u4e3a <code>3<\/code> \u9700\u8981\u5168\u90e8\u590d\u5236\u3001\u7c98\u8d34\u3001\u7c98\u8d34\uff0c\u4e5f\u5c31\u662f\u89813\u6b21\u3002\u6211\u4eec\u518d\u6765\u770b\u770b\u8fd9\u6837\u4e00\u4e2a\u4e1c\u897f\uff1a<code>12<\/code> \u9664\u4ee5 <code>2<\/code> \u7b49\u4e8e <code>6<\/code>\uff0c\u8fd9\u91cc\u64cd\u4f5c\u6b21\u6570+2\uff0c<code>6<\/code> \u9664\u4ee5 <code>2<\/code> \u7b49\u4e8e <code>3<\/code>\uff0c\u8fd9\u91cc\u64cd\u4f5c\u6b21\u6570+2\uff0c<code>3<\/code> \u9664\u4ee5 <code>3<\/code> \u7b49\u4e8e <code>1<\/code>\uff0c\u8fd9\u91cc\u64cd\u4f5c\u6b21\u6570+3\u30022 + 2 + 3 = 6\u3002\u4f60\u4f1a\u60ca\u5947\u7684\u53d1\u73b0\uff1a\u53ea\u9700\u8981\u627e\u5230\u80fd\u6574\u9664n\u7684\u9664\u6570\uff0c\u4e4b\u540e\u5168\u90e8\u52a0\u8d77\u6765\u5c31\u7b49\u4e8e\u6700\u540e\u7b54\u6848\u4e86\u3002<\/p>\n<p>\u4e0d\u76f8\u4fe1\uff1f\u518d\u6765\u8bd5\u4e00\u4e2a\uff01<code>25<\/code> \u9664\u4ee5 <code>5<\/code> \u7b49\u4e8e <code>5<\/code>\uff0c\u64cd\u4f5c\u6b21\u6570+5\uff1b<code>5<\/code> \u9664\u4ee5 <code>5<\/code> \u7b49\u4e8e <code>1<\/code>\uff0c\u64cd\u4f5c\u6b21\u6570+5\uff0c\u6700\u7ec8\u7b54\u6848\uff1a5 + 5 = 10\u3002\u662f\u4e0d\u662f\u611f\u89c9\u6709\u70b9\u795e\u5947\uff1f\u5176\u5b9e\u8fd9\u5c31\u662f\u8d28\u56e0\u6570\u7684\u5206\u89e3\uff0c<code>25<\/code> \u80fd\u5206\u6210 <code>5<\/code>  \u548c <code>5<\/code>\u3002<code>12<\/code> \u80fd\u5206\u6210 <code>2<\/code> \u548c <code>2<\/code> \u548c <code>3<\/code> \uff0c\u56e0\u6b64\u6700\u5c0f\u64cd\u4f5c\u6570\u4e3a7\u3002\u56e0\u6b64\u6700\u4e0a\u9762\u7684 <code>741<\/code> \u5206\u89e3\u8d28\u56e0\u6570\u4e3a <code>19<\/code> \u548c <code>13<\/code> \u548c <code>3<\/code>\uff0c\u6240\u4ee5\u5176\u6700\u5c0f\u64cd\u4f5c\u6570\u4e3a <code>35<\/code>\u3002<\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u63a5\u8fd1\u53cc\u767e\uff0c\u9644\u56fe\uff1a<\/p>\n<p><\/p>\n<div class=\"image-package\">\n<div class=\"image-container\" style=\"max-width: 700px; max-height: 521px;\">\n<div class=\"image-view\" data-width=\"864\" data-height=\"521\"><img decoding=\"async\" src=\"https:\/\/obagg.com\/wp-content\/uploads\/2024\/11\/frc-e7f7a368a123ade9ced6f76f973794c9.jpg\"><\/div>\n<\/div>\n<div class=\"image-caption\"><\/div>\n<\/div>\n<h4>\u6570\u5b66\u89c4\u5f8b\u6cd5\u4ee3\u7801<\/h4>\n<pre><code>class Solution {\n    public int minSteps(int n) {\n        int result = 0;\n        int i;\n        \/\/\u5f53 n \u88ab\u5206\u89e3\u5230 1 \u65f6\uff0c\u9000\u51fa\u5faa\u73af\n        while(n != 1){\n            for( i = 2; i <\/code><\/pre>\n<hr>\n<h3>2.\u52a8\u6001\u89c4\u5212(LeetCode\u5b98\u65b9\u9898\u89e3)<\/h3>\n<h5>1.\u52a8\u6001\u89c4\u5212\u6280\u5de7<\/h5>\n<p>\u5148\u7b80\u5355\u8bf4\u8bf4\u52a8\u6001\u89c4\u5212\u7684\u4e00\u4e9b\u6280\u5de7\u5427\u3002<\/p>\n<ul>\n<li>\u786e\u5b9a\u597ddp\u6570\u7ec4\u7684\u542b\u4e49\uff0c\u4e00\u5b9a\u8981\u7406\u89e3dp[i]\u6240\u8868\u793a\u7684\u662f\u4ec0\u4e48<\/li>\n<li>\u52a8\u6001\u89c4\u5212\u7684\u6570\u636e\u901a\u5e38\u662f\u7531\u524d\u9762\u4e00\u4e2a\u6570\u636e\u63a8\u5bfc\u6f14\u53d8\u800c\u6765\u7684\uff0c\u56e0\u6b64\u9700\u8981\u5f97\u51fa\u63a8\u5bfc\u516c\u5f0f<\/li>\n<li>\u6700\u540e\u5c31\u662fdp\u6570\u7ec4\u7684\u521d\u59cb\u5316\u4e86\uff0c\u8fd9\u4e2a\u9700\u8981\u989d\u5916\u6ce8\u610f\uff0c\u56e0\u4e3a\u521d\u59cb\u5316\u4e00\u65e6\u6709\u95ee\u9898\uff0c\u5c31\u4f1a\u5bfc\u81f4\u6700\u7ec8\u7b54\u6848\u51fa\u9519<\/li>\n<\/ul>\n<h5>2.\u601d\u8def<\/h5>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u8fd8\u662f\u62ff <code>12<\/code> \u6765\u8bf4\u5427\uff0c<code>12 = 1 -&gt; 2 -&gt; 3 -&gt; 6 -&gt; 12<\/code>\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0\u8981\u5f97\u51fa <code>12<\/code> \u7684\u6700\u5c0f\u64cd\u4f5c\u6b21\u6570\uff0c\u9700\u8981\u77e5\u9053 <code>6<\/code> \u7684\u6700\u5c0f\u64cd\u4f5c\u6b21\u6570\u518d\u52a0\u4e0a\u590d\u5236\u7c98\u8d34\u7684\u6b21\u6570\uff082\u6b21\uff09\uff0c\u8fdb\u800c\u9700\u8981\u77e5\u9053 <code>3<\/code> \u7684\u6700\u5c0f\u64cd\u4f5c\u6b21\u6570\u518d\u52a0\u4e0a\u590d\u5236\u7c98\u8d34\u7684\u6b21\u6570\uff082\u6b21\uff09&#8230;\u603b\u7684\u6765\u8bf4\u5c31\u662f\u5982\u679c\u8981\u627e\u51fa <code>i<\/code> \u4e2a <code>A<\/code> \uff0c\u5219\u5fc5\u5b9a\u8981\u5148\u627e\u5230 <code>i<\/code> \u7684\u56e0\u6570 <code>j<\/code> ,\u800c\u540e\u901a\u8fc7 <code>i \/ j<\/code> \u6b21\u590d\u5236\u7c98\u8d34\u5f97\u5230 <code>i<\/code> \u4e2a <code>A<\/code> \u56e0\u6b64\u4f1a\u53d1\u73b0\u8fd9\u4e2a\u9012\u63a8\u89c4\u5f8b\uff1a\n<\/p>\n<div class=\"image-package\">\n<div class=\"image-container\" style=\"max-width: 218px; max-height: 55px;\">\n<div class=\"image-view\" data-width=\"218\" data-height=\"55\"><img decoding=\"async\" src=\"https:\/\/obagg.com\/wp-content\/uploads\/2024\/11\/frc-4f44bc20c6356055491e6d7b2c294a1d.png\"><\/div>\n<\/div>\n<div class=\"image-caption\">\u9012\u63a8\u516c\u5f0f<\/div>\n<\/div>\n<p>\n\u5176\u4e2d\uff0c <code>j | i<\/code> \u8868\u793a <code>j<\/code> \u80fd\u6574\u9664 <code>i<\/code> \uff0c<code>i \/ j<\/code> \u8868\u793a\u590d\u5236\u7c98\u8d34\u7684\u6b21\u6570\u3002\u5bf9\u4e8e\u6bcf\u4e00\u4e2a <code>f[i]<\/code> \u53ea\u9700\u8981\u7b49\u4e8e\u6700\u5c0f\u7684 <code>f[j] + i \/ j<\/code>\u3002<\/p>\n<hr>\n<pre><code>class Solution {\n    public int minSteps(int n) {\n        int[] f = new int[n + 1];\n        for (int i = 2; i <\/code><\/pre>\n<p>Please credit: <a href=\"https:\/\/obagg.com\">OBA Blog<\/a> &raquo; <a href=\"https:\/\/obagg.com\/index.php\/2024\/11\/23\/%e7%ae%97%e6%b3%95%e7%bb%83%e4%b9%a0%ef%bc%9a%e5%8f%aa%e6%9c%89%e4%b8%a4%e4%b8%aa%e9%94%ae%e7%9a%84%e9%94%ae%e7%9b%98%ef%bc%88%e6%95%b0%e5%ad%a6%e6%b3%95%ef%bc%8c%e5%8a%a8%e6%80%81%e8%a7%84%e5%88%92\/\">\u7b97\u6cd5\u7ec3\u4e60\uff1a\u53ea\u6709\u4e24\u4e2a\u952e\u7684\u952e\u76d8\uff08\u6570\u5b66\u6cd5\uff0c\u52a8\u6001\u89c4\u5212\uff09<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4e00.\u524d\u8a00 \u53c8\u5230\u4e86\u8bb0\u5f55\u4ee3\u7801\u7684\u65f6\u5019\u4e86\uff0c\u8fd9\u9053\u9898\u6765\u81eaLeetCode\uff0c\u53ea\u6709\u4e24\u4e2a\u952e\u7684\u952e\u76d8\uff1a \u6700\u521d\u8bb0\u4e8b\u672c\u4e0a\u53ea\u6709\u4e00\u4e2a\u5b57\u7b26 &#8216;A&#8217; \u3002\u4f60\u6bcf\u6b21\u53ef\u4ee5\u5bf9\u8fd9\u4e2a\u8bb0\u4e8b\u672c\u8fdb\u884c\u4e24\u79cd\u64cd\u4f5c\uff1a Copy All\uff08\u590d\u5236\u5168\u90e8\uff09\uff1a\u590d\u5236\u8fd9\u4e2a\u8bb0\u4e8b\u672c\u4e2d\u7684\u6240\u6709\u5b57\u7b26\uff08\u4e0d\u5141\u8bb8\u4ec5\u590d\u5236\u90e8\u5206\u5b57\u7b26\uff09\u3002 Paste\uff08\u7c98\u8d34\uff09\uff1a\u7c98\u8d34 \u4e0a\u4e00\u6b21 \u590d\u5236\u7684\u5b57\u7b26\u3002 \u7ed9\u4f60\u4e00\u4e2a\u6570\u5b57 n \uff0c\u4f60\u9700\u8981\u4f7f\u7528\u6700\u5c11\u7684\u64cd\u4f5c\u6b21\u6570\uff0c\u5728\u8bb0\u4e8b\u672c\u4e0a\u8f93\u51fa \u6070\u597d n \u4e2a &#8216;A&#8217; \u3002\u8fd4\u56de\u80fd\u591f\u6253\u5370\u51fa n \u4e2a &#8216;A&#8217; \u7684\u6700\u5c11\u64cd\u4f5c\u6b21\u6570\u3002 \u4e0b\u9762\u7ed9\u51fa\u4e24\u4e2a\u4f8b\u5b50\uff1a \u793a\u4f8b1\uff1a \u8f93\u5165\uff1a3 \u8f93\u51fa\uff1a3 \u89e3\u91ca\uff1a \u6700\u521d, \u53ea\u6709\u4e00\u4e2a\u5b57\u7b26 &#8216;A&#8217;\u3002 \u7b2c 1 \u6b65, \u4f7f\u7528 Copy All \u64cd\u4f5c\u3002 \u7b2c 2 \u6b65, \u4f7f\u7528 Paste \u64cd\u4f5c\u6765\u83b7\u5f97 &#8216;AA&#8217;\u3002 \u7b2c 3 \u6b65, \u4f7f\u7528 Paste \u64cd\u4f5c\u6765\u83b7\u5f97 &#8216;AAA&#8217;\u3002 \u793a\u4f8b2\uff1a \u8f93\u5165\uff1an = 1 \u8f93\u51fa\uff1a0 \u4e8c.\u9898\u89e3 \u9996\u5148\u8bf4\u8bf4\u7b14\u8005\u5199\u8fd9\u9053\u9898\u7684\u7ecf\u5386\u5427\uff0c\u4e0d\u6015\u5927\u5bb6\u7b11\u8bdd\uff0c\u8fd9\u9053\u9898\u6211\u8db3\u8db3\u5199\u4e863\u5c0f\u65f6&#8230;\u6700\u5f00\u59cb\u770b\u5230\u8fd9\u9053\u9898\u7684\u65f6\u5019\u6211\u60f3\u7684\u662f\u6211\u53ef\u4ee5\u5c06 n \u4ee5\u524d\u7684\u64cd\u4f5c A \u7684\u6b21\u6570\u4ee5\u6b21\u6570\u4e3a\u952e\u7528 Hashmap \u5b58\u8d77\u6765\uff0c\u7136\u540e\u9047\u5230 n \u7684\u65f6\u5019\u76f4\u63a5\u53bb Hashmap \u91cc\u9762\u62ff\uff0c\u5f53\u6211\u53bb\u63d0\u4ea4\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u6709\u4e9b\u6d4b\u8bd5\u7528\u4f8b\u662f\u8fc7\u4e0d\u4e86\u7684\uff0c\u6bd4\u82e5\u8bf4741\u3002\u7136\u540e\u6211\u91cd\u65b0\u601d\u8003\uff0c\u53d1\u73b0\u53ef\u4ee5\u7528\u9012\u5f52\uff0c\u4f46\u662f\u7531\u4e8e\u601d\u8003\u6df1\u5ea6\u4e0d\u591f\uff0c\u53c8\u6709\u4e00\u4e9b\u60c5\u51b5\u6ca1\u8003\u8651\u5230\uff0c\u53bb\u63d0\u4ea4\u7684\u53c8\u6570\u6b21\u5931\u8d25&#8230;\u771f\u7684\u607c\u706b\u3002 \u7531\u4e8e\u9012\u5f52\u4ece\u6700\u5f00\u59cb\u5c31\u6ca1\u8003\u8651\u5230\u90a3\u79cd\u60c5\u51b5\uff0c\u56e0\u6b64\u6539\u8d77\u6765\u7279\u522b\u9ebb\u70e6\uff0c\u800c\u8fd9\u4e0d\u5f97\u4e0d\u4f7f\u6211\u91cd\u65b0\u9009\u62e9\u4e00\u6761\u8def\u51fa\u53d1\u3002\u6240\u4ee5\u7531\u6b64\u770b\u6765\u554a\uff0c\u505a\u9898\u4e4b\u524d\u771f\u8981\u9759\u4e0b\u5fc3\u6765\u601d\u8003\uff0c\u601d\u8003\u8303\u56f4\u8981\u5e7f\u4e00\u70b9\u3002 \u63a5\u4e0b\u6765\u5c31\u8bf4\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff0c\u6211\u79f0\u4e4b\u4e3a\u6570\u5b66\u89c4\u5f8b\u6cd5\u3002 1.\u6570\u5b66\u89c4\u5f8b\u6cd5 \u5148\u4e3e\u4e00\u4e9b\u7b80\u5355\u7684\u4f8b\u5b50\uff1a \u5f53\u8f93\u5165\u4e0d\u540c\u7684 n \u65f6\uff0c\u5bf9\u5e94\u8f93\u51fa\u7684\u503c\uff1a 1 = 0 2 = 1 2 &#8211;&gt; 2\u6b21\/\/\u56e0\u4e3a\u9700\u8981\u590d\u5236\u4e00\u6b21\uff0c\u7c98\u8d34\u4e00\u6b21\uff0c\u56e0\u6b64\u662f2 7 = 1 2 3 4 5 6 7 &#8211;&gt; 7\u6b21\/\/ 1 + 1 + 1 + 1 + 1 + 1 + 1 = 7 12 = 1 2 3 6 12 &#8211;&gt; 7\u6b21 \/\/2 + 1 + 2 + [&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":[],"class_list":["post-251","post","type-post","status-publish","format-standard","hentry","category-share"],"_links":{"self":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":0,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"wp:attachment":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}