{"id":29268,"date":"2024-11-25T09:34:22","date_gmt":"2024-11-25T01:34:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29268\/"},"modified":"2024-11-25T09:34:22","modified_gmt":"2024-11-25T01:34:22","slug":"%e9%80%92%e5%bd%92%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%ae%9e%e4%be%8b%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29268\/","title":{"rendered":"\u9012\u5f52\u5c0f\u7a0b\u5e8f\u5b9e\u4f8b\u4ee3\u7801"},"content":{"rendered":"<p style=\"text-align: left\">\u8fd9\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u9012\u5f52\u5c0f\u7a0b\u5e8f\u793a\u4f8b\u4ee3\u7801<\/p>\n<pre># -*- coding:utf-8 -*-\r\n \r\n__author__ = 'Abel Xu'\r\n \r\n \r\ndef func(n):\r\n    \"\"\"\r\n    T(n) = 4T(n\/2)+n\r\n    = 2n^2-n\r\n    :param n:\r\n    :return:\r\n    \"\"\"\r\n    if n==0:\r\n        return 0\r\n \r\n    return 4 * func(n\/2) + n\r\n \r\n# \u53e6\u4e00\u5957\u5199\u6cd5\r\nf = lambda x: x and 4*f(x\/2)+x or 0\r\n \r\nif __name__ == '__main__':\r\n \r\n    for i in xrange(0, 6, 2):\r\n        print(func(i))\r\n \r\n    print f(4)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9012\u5f52\u5c0f\u7a0b\u5e8f\u5b9e\u4f8b\u4ee3\u7801\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u9012\u5f52\u5c0f\u7a0b\u5e8f\u793a\u4f8b\u4ee3\u7801 # -*- coding:utf-8 -*- __author__ = &#8216;Abel Xu&#8217; def func(n): &#8220;&#8221;&#8221; T(n) = 4T(n\/2)+n = 2n^2-n :param n: :return: &#8220;&#8221;&#8221; if n==0: return 0 return 4 * func(n\/2) + n # \u53e6\u4e00\u5957\u5199\u6cd5 f = lambda x: x and 4*f(x\/2)+x or 0 if __name__ == &#8216;__main__&#8217;: for i in xrange(0, 6, 2): print(func(i)) print f(4) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-29268","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29268"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29268\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}