{"id":3311,"date":"2023-10-25T09:42:50","date_gmt":"2023-10-25T01:42:50","guid":{"rendered":"https:\/\/white-night.club\/?p=3311"},"modified":"2023-11-09T11:07:46","modified_gmt":"2023-11-09T03:07:46","slug":"ad95","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/25\/ad95\/","title":{"rendered":"2485.\u00a0\u627e\u51fa\u4e2d\u67a2\u6574\u6570"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u6b63\u6574\u6570\u00a0<code>n<\/code>\u00a0\uff0c\u627e\u51fa\u6ee1\u8db3\u4e0b\u8ff0\u6761\u4ef6\u7684<strong>\u00a0\u4e2d\u67a2\u6574\u6570<\/strong>\u00a0<code>x<\/code>\u00a0\uff1a<\/p>\n\n\n\n<ul>\n<li><code>1<\/code>&nbsp;\u548c&nbsp;<code>x<\/code>&nbsp;\u4e4b\u95f4\u7684\u6240\u6709\u5143\u7d20\u4e4b\u548c\u7b49\u4e8e&nbsp;<code>x<\/code>&nbsp;\u548c&nbsp;<code>n<\/code>&nbsp;\u4e4b\u95f4\u6240\u6709\u5143\u7d20\u4e4b\u548c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8fd4\u56de\u4e2d\u67a2\u6574\u6570<em>&nbsp;<\/em><code>x<\/code>&nbsp;\u3002\u5982\u679c\u4e0d\u5b58\u5728\u4e2d\u67a2\u6574\u6570\uff0c\u5219\u8fd4\u56de&nbsp;<code>-1<\/code>&nbsp;\u3002\u9898\u76ee\u4fdd\u8bc1\u5bf9\u4e8e\u7ed9\u5b9a\u7684\u8f93\u5165\uff0c\u81f3\u591a\u5b58\u5728\u4e00\u4e2a\u4e2d\u67a2\u6574\u6570\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>n = 8\n<strong>\u8f93\u51fa\uff1a<\/strong>6\n<strong>\u89e3\u91ca\uff1a<\/strong>6 \u662f\u4e2d\u67a2\u6574\u6570\uff0c\u56e0\u4e3a 1 + 2 + 3 + 4 + 5 + 6 = 6 + 7 + 8 = 21 \u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>n = 1\n<strong>\u8f93\u51fa\uff1a<\/strong>1\n<strong>\u89e3\u91ca\uff1a<\/strong>1 \u662f\u4e2d\u67a2\u6574\u6570\uff0c\u56e0\u4e3a 1 = 1 \u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>n = 4\n<strong>\u8f93\u51fa\uff1a<\/strong>-1\n<strong>\u89e3\u91ca\uff1a<\/strong>\u53ef\u4ee5\u8bc1\u660e\u4e0d\u5b58\u5728\u6ee1\u8db3\u9898\u76ee\u8981\u6c42\u7684\u6574\u6570\u3002<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>1 &lt;= n &lt;= 1000<\/code><\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u524d\u7f00\u548c<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u770b\u9898\u89e3\u7528\u7684\u662f\u7b49\u5dee\u6570\u5217\u524dn\u9879\u548c\u7684\u516c\u5f0f&#8230;\u7b49\u5dee\u6570\u5217\u6c42\u548c\u7684\u516c\u5f0f\u65e9\u5fd8\u7684\u5dee\u4e0d\u591a\u4e86\uff0c\u611f\u89c9&#8230;\u4e0d\u5982\u524d\u7f00\u548c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\r\npublic:\r\n    int pivotInteger(int n) {\r\n        int mid=-1;\r\n        vector&lt;int>sum;\r\n        sum.resize(n+1);\r\n        for(int i=1;i&lt;=n;i++)\r\n        {\r\n            sum&#91;i]=i+sum&#91;i-1];\r\n        }\r\n        for(int i=1;i&lt;=n;i++)\r\n        {\r\n            if(sum&#91;n]-sum&#91;i-1]==sum&#91;i])\r\n            {\r\n                mid=i;\r\n            }\r\n        }\r\n        return mid;\r\n    }\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u524d\u7f00\u548c<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3311"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=3311"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3311\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=3311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}