{"id":686,"date":"2020-06-22T15:21:02","date_gmt":"2020-06-22T07:21:02","guid":{"rendered":"http:\/\/www.guanhaobo.cn\/?p=686"},"modified":"2020-06-22T15:21:02","modified_gmt":"2020-06-22T07:21:02","slug":"jz8-%e8%b7%b3%e5%8f%b0%e9%98%b6","status":"publish","type":"post","link":"https:\/\/www.guanhaobo.cn\/?p=686","title":{"rendered":"JZ8 \u2014 \u8df3\u53f0\u9636"},"content":{"rendered":"<h3>\u9898\u76ee\u63cf\u8ff0<\/h3>\n<p>\u4e00\u53ea\u9752\u86d9\u4e00\u6b21\u53ef\u4ee5\u8df3\u4e0a1\u7ea7\u53f0\u9636\uff0c\u4e5f\u53ef\u4ee5\u8df3\u4e0a2\u7ea7\u3002\u6c42\u8be5\u9752\u86d9\u8df3\u4e0a\u4e00\u4e2an\u7ea7\u7684\u53f0\u9636\u603b\u5171\u6709\u591a\u5c11\u79cd\u8df3\u6cd5\uff08\u5148\u540e\u6b21\u5e8f\u4e0d\u540c\u7b97\u4e0d\u540c\u7684\u7ed3\u679c\uff09\u3002<\/p>\n<h3>\u9898\u76ee\u5206\u6790<\/h3>\n<p>\u8fd9\u9053\u9898\u548c\u4e0a\u4e00\u9898\u662f\u76f8\u540c\u7684\u9898\u76ee\uff0c\u9012\u5f52\u6216\u8005\u9012\u63a8\u90fd\u53ef\u4ee5\u89e3\u51b3\uff0c\u4e0d\u518d\u8d58\u8ff0\u3002<br \/>\n\u53c2\u8003\uff1a<a href=\"http:\/\/www.guanhaobo.cn\/?p=684\">http:\/\/www.guanhaobo.cn\/?p=684<\/a><\/p>\n<p>\u9752\u86d9\u8df3\u4e0a\u7b2cn\u7ea7\u53f0\u9636\uff0c\u4e00\u5171\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a<br \/>\n1. \u4ece\u7b2c<code>n-1<\/code>\u7ea7\u53f0\u9636\u4e00\u6b21\u8df3\u4e0a1\u7ea7\u53f0\u9636\u5230\u8fbe\u7b2cn\u7ea7\u53f0\u9636<br \/>\n2. \u4ece\u7b2c<code>n-2<\/code>\u7ea7\u53f0\u9636\u4e00\u6b21\u8df3\u4e0a2\u7ea7\u53f0\u9636\u5230\u8fbe\u7b2cn\u7ea7\u53f0\u9636<\/p>\n<p>\u56e0\u6b64\u6709<code>f[n] = f[n-1] + f[n-2]<\/code><\/p>\n<h3>C++<\/h3>\n<pre><code class=\"language-cpp line-numbers\">class Solution\n{\npublic:\n    int jumpFloor(int number)\n    {\n        if (number &lt; 3)\n            return number;\n        int a3, a2 = 2, a1 = 1;\n        for (int i = 3; i &lt;= number; i++)\n        {\n            a3 = a2 + a1;\n            a1 = a2, a2 = a3;\n        }\n        return a3;\n    }\n};\n<\/code><\/pre>\n<h3>Java<\/h3>\n<pre><code class=\"language-java line-numbers\">public class Solution {\n    public int JumpFloor(int target) {\n        if (target &lt; 3)\n            return target;\n        int a3 = 3, a2 = 2, a1 = 1;\n        for (int i = 3; i &lt;= target; i++) {\n            a3 = a2 + a1;\n            a1 = a2;\n            a2 = a3;\n        }\n        return a3;\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0 \u4e00\u53ea\u9752\u86d9\u4e00\u6b21\u53ef\u4ee5\u8df3\u4e0a1\u7ea7\u53f0\u9636\uff0c\u4e5f\u53ef\u4ee5\u8df3\u4e0a2\u7ea7\u3002\u6c42\u8be5\u9752\u86d9\u8df3\u4e0a\u4e00\u4e2an\u7ea7\u7684\u53f0\u9636\u603b\u5171\u6709\u591a\u5c11\u79cd\u8df3\u6cd5\uff08\u5148\u540e\u6b21\u5e8f\u4e0d [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[39],"class_list":["post-686","post","type-post","status-publish","format-standard","hentry","category-algo","tag-offer"],"_links":{"self":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts\/686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=686"}],"version-history":[{"count":0,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts\/686\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}