{"id":3011,"date":"2020-02-21T11:52:18","date_gmt":"2020-02-21T03:52:18","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=3011"},"modified":"2020-02-21T11:52:18","modified_gmt":"2020-02-21T03:52:18","slug":"%e3%80%90leetcode%e3%80%910062-%e4%b8%8d%e5%90%8c%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/algorithm\/3011\/","title":{"rendered":"\u3010LeetCode\u30110062 \u4e0d\u540c\u8def\u5f84"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/unique-paths\/\">https:\/\/leetcode-cn.com\/problems\/unique-paths\/<\/a><\/p>\n\n\n<pre class=\"wp-block-preformatted\"># -*- coding:utf-8 -*-<em>\n<\/em>class Solution(object):\n    def uniquePaths(self, m, n):\n        <em>\"\"\"\n        <\/em><strong><em>:type<\/em><\/strong><em> m: int\n        <\/em><strong><em>:type<\/em><\/strong><em> n: int\n        <\/em><strong><em>:rtype<\/em><\/strong><em>: int\n        \"\"\"\n        <\/em>if m == 1 or n == 1:\n            return 1\n        m = m - 1\n        n = n - 1\n        res = 1\n        for i in range(m + n, m, -1):\n            res *= i\n        for i in range(1, n + 1):\n            res \/= i\n        return int(res)\nif __name__ == '__main__':\n    m = 6\n    n = 3\n    print(Solution().uniquePaths(m, n))\n<\/pre>\n\n\n<p><strong>\u601d\u8def<\/strong>\uff1a\u5176\u4e2d\u603b\u8ba1\u8981\u6709m+n-2\u6761\u8def\u5f84\uff0c\u5176\u4e2d\u6709n-1\u6761\u8def\u5f84\u662f\u5411\u4e0b\u7684\uff0c\u56e0\u6b64\u5b9e\u9645\u4e0a\u5c31\u662f\u8ba1\u7b97C_{n-1,m+n-c}\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/leetcode-cn.com\/problems\/unique-paths\/ # &#8211; [&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":1824,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3011"}],"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=3011"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3011\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3011"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}