{"id":172,"date":"2024-04-26T16:11:31","date_gmt":"2024-04-26T08:11:31","guid":{"rendered":"https:\/\/seanxd.com\/?p=172"},"modified":"2024-04-26T16:11:33","modified_gmt":"2024-04-26T08:11:33","slug":"zerojudge-e357","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-e357\/","title":{"rendered":"ZeroJudge E357: \u905e\u8ff4\u51fd\u6578\u7df4\u7fd2"},"content":{"rendered":"\n\n\n<p class=\"\">\u5b9a\u7fa9\u4e00\u500b\u51fd\u6578 F(x)<\/p>\n\n\n\n<p class=\"\">\u82e5 x = 1\uff0c\u5247 F(x) = 1<\/p>\n\n\n\n<p class=\"\">\u82e5 x \u70ba\u5076\u6578\uff0c\u5247 F(x) = F(x\/2)<\/p>\n\n\n\n<p class=\"\">\u5176\u9918\u72c0\u6cc1\uff0cF(x) = F(x &#8211; 1) + F(x + 1)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u8f38\u5165\u53ea\u6709\u4e00\u884c\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u500b\u6b63\u6574\u6578 x (1 &lt;= x &lt;= 2000000)\u3002<\/td><td>\u8f38\u51fa\u53ea\u6709\u4e00\u884c\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u500b\u6b63\u6574\u6578 F(x)\u3002<\/td><\/tr><tr><td>6<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u672c\u984c\u53ef\u4ee5\u5beb\u4e00\u500b<strong>\u905e\u8ff4\u51fd\u5f0f<\/strong>\uff0c<strong>\u7d42\u6b62\u7684\u689d\u4ef6\u662f\u7576N = 1<\/strong>\u6642\u5c31 return N\uff0c\u7136\u5f8c\u5c07\u5076\u6578\u53ca\u5947\u6578\u7684\u5224\u65b7\u5f0f\u5beb\u597d\u7136\u5f8c <strong>cout\u905e\u8ff4(N)<\/strong> \u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=e357\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge E357: \u905e\u8ff4\u51fd\u6578\u7df4\u7fd2<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint calc (int N)\n{\n    if (N == 1) return 1;\n    if (N % 2 == 0) return calc(N\/2);\n    else return calc(N-1)+calc(N+1);\n}\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    cout &lt;&lt; calc(N) &lt;&lt; endl;\n}\n\n\/\/ZeroJudge E357\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9a\u7fa9\u4e00\u500b\u51fd\u6578 F(x) \u82e5 x = 1\uff0c\u5247 F(x) = 1 \u82e5 x \u70ba\u5076\u6578\uff0c\u5247 F(x) = F(x\/2)  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[6],"tags":[8,13,28],"class_list":["post-172","post","type-post","status-publish","format-standard","hentry","category-6","tag-8","tag-13","tag-28"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=172"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/172\/revisions"}],"predecessor-version":[{"id":173,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/172\/revisions\/173"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}