{"id":248,"date":"2023-07-06T15:56:29","date_gmt":"2023-07-06T07:56:29","guid":{"rendered":"https:\/\/solost.cn\/?p=248"},"modified":"2023-07-06T15:56:29","modified_gmt":"2023-07-06T07:56:29","slug":"376","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=248","title":{"rendered":"Codeforces Round 878 (Div. 3) &#8211; B. Binary Cafe"},"content":{"rendered":"<h2>\u9898\u76ee\u94fe\u63a5<\/h2>\n<p><a href=\"https:\/\/codeforces.com\/contest\/1840\/problem\/B\">\u94fe\u63a5<\/a><\/p>\n<h2>\u9898\u76ee\u5927\u610f<\/h2>\n<p>\u6709 <strong>k<\/strong> \u79cd\u5546\u54c1\uff0c\u7f16\u53f7\u4e3a <strong>0<\/strong> \u81f3 <strong>k<\/strong>\u2212<strong>1<\/strong>\uff0c\u7f16\u53f7\u4e3a <strong>i<\/strong> \u7684\u5546\u54c1\u7684\u4ef7\u683c\u4e3a2^i\uff0c\u95ee\u4f60\u5728\u82b1\u7684\u94b1\u6570\u4e0d\u8d85\u8fc7 <strong>n<\/strong> \u4e14\u6bcf\u79cd\u5546\u54c1\u6700\u591a\u4e70\u4e00\u4e2a\uff08\u53ef\u4ee5\u4e0d\u4e70\u6240\u6709\u5546\u54c1\uff09\u7684\u524d\u63d0\u4e0b\uff0c\u6709\u591a\u5c11\u79cd\u8d2d\u4e70\u5546\u54c1\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u67d0\u4e2a\u5546\u54c1\u53ea\u6709\u4e24\u79cd\u60c5\u51b5\uff0c\u4e70\u8fd8\u662f\u4e0d\u4e70\uff0c\u8fd9\u5c31\u50cf\u4e8c\u8fdb\u5236\uff0c\u4ece\u53f3\u5f80\u5de6\uff0c\u7b2ci\u4e2a\u4f4d0\u4ee3\u8868\u4e0d\u4e70\uff0c\u5426\u5219\u4e70\uff0c\u95eeK\u4f4d\u4ee5\u5185\uff0c\u80fd\u6709\u591a\u5c11\u4e2a\u4e8c\u8fdb\u5236\u8f6c\u6362\u4e3a10\u8fdb\u5236\u5c0f\u4e8e\u7b49\u4e8en\u3002\u5982\u679c\u6709k\u4f4d\uff0c\u90a3\u4e48\u53ef\u4ee5\u8868\u793a[0, 2^k - 1]\u7684\u6570\u5b57\u90fd\u53ef\u4ee5\u8868\u793a\u51fa\u6765\uff0c\u56e0\u4e3a2\u8fdb\u5236\u8868\u793a\u662f\u552f\u4e00\u7684\uff0c\u4f8b\u59828 = 2^3,\u518d\u6ca1\u6709\u5176\u4ed6\u7684\u8868\u793a\u529e\u6cd5\uff0c \u6240\u4ee5\u4e0d\u80fd\u88ab\u5176\u4ed6\u66ff\u4ee3\uff0c\u6240\u4ee5\uff0c[0, 2^k - 1]\u7684\u6570\u5b57\u90fd\u6709\u552f\u4e00\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u65b9\u6cd5\uff0c\u5982\u679cn &lt;= 2^k -1,\u90a3\u4e48\u6700\u591a\u8868\u793a[0, n]\u4e00\u5171n+1\u4e2a\u6570\u5b57\uff0c\u5982\u679c\u5c0f\u4e8e\u7684\u8bdd\u53ef\u4ee5\u8868\u793a[0, 2^k - 1]\u8303\u56f4\u5185\u7684\u6570\uff0c\u4e00\u51712^k\u4e2a\u3002\u53c8\u56e0\u4e3a1&lt;&lt;30\u5c31\u4f1a\u7206int,\u8d85\u8fc71e9\uff0c\u7279\u5224\u5373\u53ef<\/p>\n<pre><code class=\"lang-cpp\">#include &lt;map&gt;\n#include &lt;set&gt;\n#include &lt;cmath&gt;\n#include &lt;queue&gt;\n#include &lt;stack&gt;\n#include &lt;vector&gt;\n#include &lt;bitset&gt;\n#include &lt;cstdio&gt;\n#include &lt;cstdlib&gt;\n#include &lt;cstring&gt;\n#include &lt;fstream&gt;\n#include &lt;iostream&gt;\n#include &lt;algorithm&gt;\n#include &lt;unordered_map&gt;\n#include &lt;unordered_set&gt;\n\n#define x first\n#define y second\n#define endl &#039;\\n&#039;\n#define IOS                       \\\n    ios_base::sync_with_stdio(0); \\\n    cin.tie(0);                   \\\n    cout.tie(0);\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair&lt;ll, ll&gt; pll;\ntypedef pair&lt;int, int&gt; pii;\ntypedef unsigned long long ull;\n\nconst int INF = 0x3f3f3f3f, mod = 1000000007;\nconst int N = 2e5 + 10;\n\nvoid solve()\n{\n    int n, k;\n    cin &gt;&gt; n &gt;&gt; k;\n    if(k &gt;= 30 || n &lt;= pow(2, k) - 1){\n        cout &lt;&lt; (n + 1) &lt;&lt; endl;\n    }\n    else{\n        cout &lt;&lt; (1 &lt;&lt; k) &lt;&lt; endl;\n    }\n}\nint main()\n{\n    IOS;\n    int t = 1;\n    cin &gt;&gt; t;\n    while (t--) {\n        solve();\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u94fe\u63a5 \u94fe\u63a5 \u9898\u76ee\u5927\u610f \u6709 k \u79cd\u5546\u54c1\uff0c\u7f16\u53f7\u4e3a 0 \u81f3 k\u22121\uff0c\u7f16\u53f7\u4e3a i \u7684\u5546\u54c1\u7684\u4ef7\u683c\u4e3a2^i\uff0c\u95ee\u4f60\u5728\u82b1\u7684\u94b1\u6570\u4e0d\u8d85\u8fc7 n \u4e14\u6bcf\u79cd\u5546\u54c1\u6700\u591a\u4e70\u4e00\u4e2a\uff08\u53ef\u4ee5\u4e0d\u4e70\u6240\u6709\u5546\u54c1\uff09\u7684\u524d\u63d0\u4e0b\uff0c\u6709\u591a\u5c11\u79cd\u8d2d\u4e70\u5546\u54c1\u7684\u65b9\u5f0f\u3002 \u67d0\u4e2a\u5546\u54c1\u53ea\u6709\u4e24\u79cd\u60c5\u51b5\uff0c\u4e70\u8fd8\u662f\u4e0d\u4e70\uff0c\u8fd9\u5c31\u50cf\u4e8c\u8fdb\u5236\uff0c\u4ece\u53f3\u5f80\u5de6\uff0c\u7b2ci\u4e2a\u4f4d0\u4ee3\u8868\u4e0d\u4e70\uff0c\u5426\u5219\u4e70\uff0c\u95eeK\u4f4d\u4ee5\u5185\uff0c\u80fd\u6709\u591a\u5c11\u4e2a\u4e8c\u8fdb\u5236\u8f6c\u6362\u4e3a10\u8fdb\u5236\u5c0f\u4e8e\u7b49\u4e8en\u3002\u5982\u679c\u6709k\u4f4d\uff0c\u90a3\u4e48\u53ef\u4ee5\u8868\u793a[0, 2^k - 1]\u7684\u6570\u5b57\u90fd\u53ef\u4ee5\u8868\u793a\u51fa\u6765\uff0c\u56e0\u4e3a2\u8fdb\u5236\u8868\u793a\u662f\u552f\u4e00\u7684\uff0c\u4f8b\u59828 = 2^3,\u518d\u6ca1\u6709\u5176\u4ed6\u7684\u8868\u793a\u529e\u6cd5\uff0c \u6240\u4ee5\u4e0d\u80fd\u88ab\u5176\u4ed6\u66ff\u4ee3\uff0c\u6240\u4ee5\uff0c[0, 2^k - 1]\u7684\u6570\u5b57\u90fd\u6709\u552f\u4e00\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u65b9\u6cd5\uff0c\u5982\u679cn &lt;= 2^k -1,\u90a3\u4e48\u6700\u591a\u8868\u793a[0, n]\u4e00\u5171n+1\u4e2a\u6570\u5b57\uff0c\u5982\u679c\u5c0f\u4e8e\u7684\u8bdd\u53ef\u4ee5\u8868\u793a[0, 2^k - 1]\u8303\u56f4\u5185\u7684\u6570\uff0c\u4e00\u51712^k\u4e2a\u3002\u53c8\u56e0\u4e3a1&lt;&lt;30\u5c31\u4f1a\u7206int,\u8d85\u8fc71e9\uff0c\u7279\u5224\u5373\u53ef #include &lt;map&gt; #include &lt;set&gt; #include &lt;cmath&gt; #include &lt;queue&gt; #include &lt;stack&gt; #include &lt;vector&gt; #include &lt;bitset&gt; #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;cstring&gt; #include &lt;fstream&gt; #include &lt;iostream&gt; #include [&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":[5,11],"class_list":["post-248","post","type-post","status-publish","format-standard","hentry","category-solution","tag-5","tag-11"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/248","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=248"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/248\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}