{"id":27,"date":"2023-01-21T21:37:00","date_gmt":"2023-01-21T13:37:00","guid":{"rendered":"https:\/\/solost.cn\/?p=27"},"modified":"2023-02-02T00:52:35","modified_gmt":"2023-02-01T16:52:35","slug":"54","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=27","title":{"rendered":"2023\u725b\u5ba2\u5bd2\u5047\u7b97\u6cd5\u57fa\u7840\u96c6\u8bad\u84253 B-\u52c9\u5f3a\u62fc\u51d1\u7684\u8bb0\u5fc6"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/2419413528.png\" alt=\"\" title=\"\">\u9898\u76ee\u5927\u610f\uff0c\u4e00\u5171\u6709n\u5757\u79ef\u6728\uff0c\u6bcf\u5757\u957f\u5ea6\u662fn\/2\u5411\u4e0a\u53d6\u6574\uff0c\u95ee\u6700\u5927\u62fc\u6210\u6b63\u65b9\u5f62\u7684\u6700\u5927\u8fb9\u957f\u3002<\/p>\n<p>\u89e3\u6cd5\uff1al\u662fn\/2\u5411\u4e0a\u53d6\u6574\uff0c\u5148\u7528l\u5757\u6728\u5757\u62fc\u6210\u4e00\u4e2a\u6b63\u65b9\u5f62\uff0c\u6bcf\u589e\u52a0\u4e00\u5c42\u9700\u8981\u4e09\u4e2a\u6728\u5757\uff0c\u7136\u540e\u770bn-l\u4ee5\u540e\u8fd8\u80fd\u5269\u591a\u5c11\u5757\uff0c\u7136\u540e\u518d\u6574\u96643\uff0c\u770b\u770b\u80fd\u51d1\u51fa\u51e0\u4e2a\u5c31\u662f\u7b54\u6848\u4e86,\u7ecf\u8fc7\u4e25\u5bc6\u7684\u731c\u6d4b\uff0c\u53ea\u67092\u662f\u65e0\u89e3\u7684\uff0c\u7ecf\u8fc7\u9a8c\u8bc1\uff0c\u5982\u679c\u591a\u51fa\u6765\u6728\u5757\u7684\u8bdd\uff0c\u53ef\u4ee5\u7f29\u77ed\u5df2\u7ecf\u653e\u597d\u7684\u6728\u5757\u957f\u5ea6\uff0c\u6240\u4ee5\u603b\u662f\u653e\u7684\u4e0b\u7684\u3002\u8fd9\u91cc\u6211\u7528\u4e86ceil(n * 1.0 \/ 2)\u51fa\u4e86\u95ee\u9898\uff0c\u6240\u4ee5\u4ee5\u540e\u7684\u6728\u5757\u90fd\u4e0d\u7528ceil\u51fd\u6570\uff0c\u5411\u4e0a\u53d6\u6574\u662f(n + (n - 1) \/ 2,\u56db\u820d\u4e94\u5165\u662f(n + 0.5)<\/p>\n<pre><code class=\"C++\">#include&lt;map&gt;\n#include&lt;set&gt;\n#include&lt;stack&gt;\n#include&lt;queue&gt;\n#include&lt;cmath&gt;\n#include&lt;vector&gt;\n#include&lt;bitset&gt;\n#include&lt;cstdio&gt;\n#include&lt;cstring&gt;\n#include&lt;fstream&gt;\n#include&lt;cstdlib&gt;\n#include&lt;iostream&gt;\n#include&lt;algorithm&gt;\n#include&lt;unordered_map&gt;\n\nusing namespace std;\n#define endl &#039;\\n&#039;\n#define IOS                       \\\n    ios_base::sync_with_stdio(0); \\\n    cin.tie(0);                   \\\n    cout.tie(0);\ntypedef long long ll;\ntypedef pair&lt;int,int&gt; PII;\ntypedef unsigned long long ull;\nconst int INF = 0x3f3f3f3f, mod = 1000000007;\nconst int N = 2e5 + 10;\n\nvoid solve(){\n    ll n;\n    cin &gt;&gt; n;\n    if(n == 2){\n        cout &lt;&lt; &quot;-1\\n&quot;;\n    }\n    else{\n        ll l = (n + 1) \/ 2;\n        ll ans = l + (n - l) \/ 3;\n        cout &lt;&lt; ans &lt;&lt; endl;\n    }\n}\nint main(){\n    IOS;\n    int t;\n    cin &gt;&gt; t;\n    while(t--){\n        solve();\n    }\n    return 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u5927\u610f\uff0c\u4e00\u5171\u6709n\u5757\u79ef\u6728\uff0c\u6bcf\u5757\u957f\u5ea6\u662fn\/2\u5411\u4e0a\u53d6\u6574\uff0c\u95ee\u6700\u5927\u62fc\u6210\u6b63\u65b9\u5f62\u7684\u6700\u5927\u8fb9\u957f\u3002 \u89e3\u6cd5\uff1al\u662fn\/2\u5411\u4e0a\u53d6\u6574\uff0c\u5148\u7528l\u5757\u6728\u5757\u62fc\u6210\u4e00\u4e2a\u6b63\u65b9\u5f62\uff0c\u6bcf\u589e\u52a0\u4e00\u5c42\u9700\u8981\u4e09\u4e2a\u6728\u5757\uff0c\u7136\u540e\u770bn-l\u4ee5\u540e\u8fd8\u80fd\u5269\u591a\u5c11\u5757\uff0c\u7136\u540e\u518d\u6574\u96643\uff0c\u770b\u770b\u80fd\u51d1\u51fa\u51e0\u4e2a\u5c31\u662f\u7b54\u6848\u4e86,\u7ecf\u8fc7\u4e25\u5bc6\u7684\u731c\u6d4b\uff0c\u53ea\u67092\u662f\u65e0\u89e3\u7684\uff0c\u7ecf\u8fc7\u9a8c\u8bc1\uff0c\u5982\u679c\u591a\u51fa\u6765\u6728\u5757\u7684\u8bdd\uff0c\u53ef\u4ee5\u7f29\u77ed\u5df2\u7ecf\u653e\u597d\u7684\u6728\u5757\u957f\u5ea6\uff0c\u6240\u4ee5\u603b\u662f\u653e\u7684\u4e0b\u7684\u3002\u8fd9\u91cc\u6211\u7528\u4e86ceil(n * 1.0 \/ 2)\u51fa\u4e86\u95ee\u9898\uff0c\u6240\u4ee5\u4ee5\u540e\u7684\u6728\u5757\u90fd\u4e0d\u7528ceil\u51fd\u6570\uff0c\u5411\u4e0a\u53d6\u6574\u662f(n + (n - 1) \/ 2,\u56db\u820d\u4e94\u5165\u662f(n + 0.5) #include&lt;map&gt; #include&lt;set&gt; #include&lt;stack&gt; #include&lt;queue&gt; #include&lt;cmath&gt; #include&lt;vector&gt; #include&lt;bitset&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;fstream&gt; #include&lt;cstdlib&gt; #include&lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;unordered_map&gt; using namespace std; #define endl &#039;\\n&#039; #define IOS \\ ios_base::sync_with_stdio(0); \\ cin.tie(0); \\ cout.tie(0); typedef long long ll; typedef pair&lt;int,int&gt; PII; typedef unsigned long long ull; const [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[4,5,6,7],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-solution","tag-4","tag-5","tag-6","tag-7"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}