{"id":2942,"date":"2020-02-15T17:21:24","date_gmt":"2020-02-15T09:21:24","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=2942"},"modified":"2020-02-15T17:21:24","modified_gmt":"2020-02-15T09:21:24","slug":"%e3%80%90leetcode%e3%80%91l343%e5%89%91%e6%8c%87offer-%e8%af%81%e4%b9%a6%e6%8b%86%e5%88%86%e5%89%aa%e7%bb%b3%e5%ad%90","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/algorithm\/2942\/","title":{"rendered":"\u3010LeetCode\u30110343&amp;\u5251\u6307Offer \u8bc1\u4e66\u62c6\u5206&amp;\u526a\u7ef3\u5b50"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/integer-break\/\">https:\/\/leetcode-cn.com\/problems\/integer-break\/<\/a><\/p>\n\n\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/jian-sheng-zi-lcof\/\">https:\/\/leetcode-cn.com\/problems\/jian-sheng-zi-lcof\/<\/a><\/p>\n\n\n<p><\/p>\n\n\n<pre class=\"wp-block-preformatted\"># -*- coding:utf-8 -*-\n<em>\n<\/em>class Solution:\n    def cuttingRope(self, n: int) -> int:\n        dp = [0 for _ in range(n+1)]\n        dp[0]  = 1\n        if n &lt;= 2:\n            return dp[n - 1]\n        # \u957f\u5ea6\n        for i in range(2, n+1):\n            for j in range(i):\n                dp[i] = max(dp[i], max(j * dp[i - j], j * (i - j)))\n        return dp[-1]\nif __name__ == '__main__':\n    n = 10\n    print(Solution().cuttingRope(n))\n<\/pre>\n\n\n<p><strong>\u601d\u8def<\/strong>\uff1a\u7b80\u5355\u7684\u52a8\u6001\u89c4\u5212\u3002\u7c7b\u4f3c\u4e8e<a rel=\"noreferrer noopener\" aria-label=\"\u52a8\u6001\u89c4\u5212\u7684\u94a2\u6761\u5207\u5272\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"http:\/\/www.sniper97.cn\/index.php\/note\/introduction_to_algorithms\/2513\/\" target=\"_blank\">\u52a8\u6001\u89c4\u5212\u7684\u94a2\u6761\u5207\u5272<\/a>\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/leetcode-cn.com\/problems\/integer-break\/ ht [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"views":2184,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/2942"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2942"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/2942\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2942"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}