{"id":2741,"date":"2023-10-17T16:31:51","date_gmt":"2023-10-17T08:31:51","guid":{"rendered":"https:\/\/white-night.club\/?p=2741"},"modified":"2023-11-09T11:07:48","modified_gmt":"2023-11-09T03:07:48","slug":"ad65","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/17\/ad65\/","title":{"rendered":"\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff1a\u52a8\u6001\u89c4\u5212"},"content":{"rendered":"\n<p>\u5728\u901a\u8fc7\u9012\u5f52\u548c\u8bb0\u5fc6\u5316\u641c\u7d22\u89e3\u51b3\u6590\u6ce2\u90a3\u5951\u6570\u5217\u540e\uff0c\u6211\u4eec\u73b0\u5728\u6765\u770b\u770b\u5982\u4f55\u901a\u8fc7\u52a8\u6001\u89c4\u5212\u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\u5217\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u52a8\u6001\u89c4\u5212<\/p>\n<cite><em>\u4ec0\u4e48\u662f\u52a8\u6001\u89c4\u5212<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5bf9\u4e8e\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff0c\u5982\u679c\u4f7f\u7528\u5355\u7eaf\u7684\u9012\u5f52\u7b97\u6cd5\uff0c\u4f1a\u5bfc\u81f4\u5197\u4f59\u8ba1\u7b97\u7684\u589e\u957f\u662f\u201c\u7206\u70b8\u6027\u201d\u7684\u3002\u4e8e\u662f\u6211\u4eec\u7528\u8bb0\u5fc6\u5316\u641c\u7d22\uff0c\u65b0\u5efa\u4e00\u4e2a\u7528\u4e8e\u5b58\u50a8\u201c\u5df2\u7ecf\u89e3\u51b3\u8fc7\u7684\u5b50\u95ee\u9898\u201d\u7684\u8868\u4ee5\u907f\u514d\u5197\u4f59\u8ba1\u7b97\u3002<\/p>\n\n\n\n<p>\u800c\u8bb0\u5fc6\u5316\u5b58\u50a8\uff0c\u5176\u5b9e\u4e5f\u7b97\u52a8\u6001\u89c4\u5212\u7684\u4e00\u79cd\u3002\u52a8\u6001\u89c4\u5212(dynamic programming\uff0c\u4fd7\u79f0dp)\u57fa\u672c\u4e0a\u5c31\u662f<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u57fa\u4e8e\u5c06\u9012\u5f52\u7b97\u6cd5\u91cd\u65b0\u5199\u6210\u975e\u9012\u5f52\u7b97\u6cd5\uff0c\u5e76\u5c06\u5b50\u95ee\u9898\u7684\u7b54\u6848\u7cfb\u7edf\u7684\u8bb0\u5f55\u5728\u8868\u4e2d<\/mark>\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff1a\u52a8\u6001\u89c4\u5212<\/p>\n<cite><em>\u5c06\u9012\u5f52\u65b9\u7a0b\u8f6c\u6362\u4e3a\u975e\u9012\u5f52\u65b9\u7a0b<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6590\u6ce2\u90a3\u5951\u7684\u9012\u5f52\u65b9\u7a0b\u4e3a\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>F(n)=F(n-1)+F(n-2)<\/em><\/strong><\/p>\n\n\n\n<p>\u8bf4\u767d\u4e86\u5c31\u662fxxx\u7684\u524d\u4e24\u9879\u4e4b\u548c\u7b49\u4e8exxx\u3002\u90a3\u6211\u4eec\u7528\u5355\u4e2a\u5faa\u73af\u4e0d\u5c31\u80fd\u89e3\u51b3\u4e86\u5417\uff1f\u628a\u6590\u6ce2\u90a3\u5951\u6570\u5217\u5f53\u4f5c\u4e00\u4e2a\u6570\u7ec4\u3002\u8fd9\u91cc\u7528leetcode\u5b98\u65b9\u9898\u89e3\u7684gif\u4f5c\u4e3a\u793a\u4f8b<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode-cn.com\/solution-static\/jianzhi_10_I\/10_I_fig1.gif\" alt=\"\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\r\n#include&lt;vector>\r\nusing namespace std;\r\n\r\nint fib(int n)\r\n{\r\n    if(n&lt;=1)\r\n    {\r\n        return n;\r\n    }\r\n    int left=0,right=1;\r\n    int result=0;\r\n    for(int i=1;i&lt;=n;i++)\r\n    {\r\n        result=left+right;\r\n        left=right;\r\n        right=result;\r\n    }\r\n    return result;\r\n}\r\nint main()\r\n{\r\n    while(true)\r\n    {\r\n        int n;\r\n        cin>>n;\r\n        cout&lt;&lt;fib(n)&lt;&lt;endl;\r\n    }\r\n}<\/code><\/pre>\n\n\n\n<p>\u6700\u540e\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(n\uff09\uff0c\u800c\u4e14\u4e5f\u4e0d\u9700\u8981\u5f00\u65b0\u7684\u7a7a\u95f4\u5b58\u653e\u8ba1\u7b97\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u8bc6\u52a8\u6001\u89c4\u5212<\/p>\n","protected":false},"author":1,"featured_media":3220,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[25,50],"tags":[102,36],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2741"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2741"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2741\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/3220"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}