{"id":255,"date":"2023-07-18T17:03:06","date_gmt":"2023-07-18T09:03:06","guid":{"rendered":"https:\/\/solost.cn\/?p=255"},"modified":"2023-07-18T17:03:06","modified_gmt":"2023-07-18T09:03:06","slug":"384","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=255","title":{"rendered":"\u201c\u8303\u5f0f\u676f\u201d2023\u725b\u5ba2\u6691\u671f\u591a\u6821\u8bad\u7ec3\u84251 &#8211; J &#8211; Roulette"},"content":{"rendered":"<h2>\u9898\u76ee\u94fe\u63a5<\/h2>\n<p><a href=\"https:\/\/ac.nowcoder.com\/acm\/contest\/57355\/J\">\u9898\u76ee\u94fe\u63a5<\/a><\/p>\n<h2>\u9898\u76ee\u5927\u610f<\/h2>\n<p>\u6709n\u5143\u94b1\uff0c\u8981\u8d5a\u5230m\u5143\u3002\u89c4\u5219\u662f\u7b2c\u4e00\u5c40\u538b1\u5143\uff0c\u8f93\u4e86\u538b\u4e4b\u524d\u538b\u76842\u500d\uff0c\u5426\u5219\u7ee7\u7eed\u538b1\u5143\uff0c\u8f93\u8d62\u7684\u6982\u7387\u90fd\u662f0.5\uff0c\u95ee\u8d62\u5230m\u5143\u7684\u6982\u7387\u662f\u591a\u5c11<\/p>\n<h2>\u9898\u89e3<\/h2>\n<p>\u4ee5\u201c\u8f93\u8f93\u8f93\u2026\u2026\u8f93\u8d62\u201d\u4e3a\u4e00\u4e2a\u5468\u671f\uff0c\u53ef\u4ee5\u8d62\u5230\u4e00\u5757\u94b1\u3002\u56e0\u800c\u9700\u8981\u7ecf\u8fc7 m \u4e2a\u8fd9\u6837\u7684\u5468\u671f\uff0c\u6709x\u5143\u53ef\u4ee5\u8f93\uff0c\u8d5a1\u5757\u7684\u6b21\u6570\u662f2^n - 1 &lt;= x\uff0cn\u5c31\u662f\u6b21\u6570\u3002\u7136\u540e\u6211\u4eec\u4e00\u5171\u6709[n, n + m - 1]\u53ef\u4ee5\u8f93\uff0c\u90a3\u4e48\u8f93x\u5143\u8d5a1\u5143\u7684\u6982\u7387\u5c31\u662f1-2^n\uff0c\u7531\u4e8em\u5f88\u5927\uff0c\u6709\u4e00\u6bb5\u533a\u95f4\u5185\u7684\u6982\u7387\u662f\u76f8\u7b49\u7684\uff0c[2^n - 1, 2^(n + 1) - 2]\u662f\u76f8\u7b49\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u4e00\u6b21\u7b97\u591a\u4e2a\u533a\u95f4\u7684\u6982\u7387<\/p>\n<h2>\u4ee3\u7801<\/h2>\n<pre><code class=\"lang-cpp\">#include &lt;algorithm&gt;\n#include &lt;bitset&gt;\n#include &lt;cmath&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;map&gt;\n#include &lt;queue&gt;\n#include &lt;set&gt;\n#include &lt;stack&gt;\n#include &lt;unordered_map&gt;\n#include &lt;unordered_set&gt;\n#include &lt;vector&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 = 998244353;\nconst int N = 2e5 + 10;\n\nll qmi(ll n, ll k, ll p = mod)\n{\n    ll res = 1 % p;\n    while (k) {\n        if (k &amp; 1)\n            res = res * n % p;\n        n = n * n % p;\n        k &gt;&gt;= 1;\n    }\n    return res;\n}\n\nvoid solve()\n{\n    ll n, m;\n    cin &gt;&gt; n &gt;&gt; m;\n    ll ans = 1;\n    for (ll i = 1; (1ll &lt;&lt; i) &lt;= n + m; i++) {\n        ll l = max((1ll &lt;&lt; i) - 1ll, n), r = min((1ll &lt;&lt; (i + 1)) - 2ll, n + m - 1);\n        \/\/\u4ecen\u5f00\u59cb\u82b1\n        if (l &gt; r)\n            continue;\n        ll p = (mod + 1 - qmi((1ll &lt;&lt; i), mod - 2)) % mod;\n        ans = ans * qmi(p, r - l + 1) % mod;\/\/r-l+1\u4ee3\u8868\u6709\u8fd9\u4e48\u591a\u4e2a\u6982\u7387\u76f8\u540c\uff0c\u6240\u4ee5\u7528\u5feb\u901f\u5e42\u76f8\u4e58\n    }\n    cout &lt;&lt; ans &lt;&lt; endl;\n}\nint main()\n{\n    \/\/ IOS;\n    int _ = 1;\n    \/\/ cin &gt;&gt; _;\n    while (_--) {\n        solve();\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u94fe\u63a5 \u9898\u76ee\u94fe\u63a5 \u9898\u76ee\u5927\u610f \u6709n\u5143\u94b1\uff0c\u8981\u8d5a\u5230m\u5143\u3002\u89c4\u5219\u662f\u7b2c\u4e00\u5c40\u538b1\u5143\uff0c\u8f93\u4e86\u538b\u4e4b\u524d\u538b\u76842\u500d\uff0c\u5426\u5219\u7ee7\u7eed\u538b1\u5143\uff0c\u8f93\u8d62\u7684\u6982\u7387\u90fd\u662f0.5\uff0c\u95ee\u8d62\u5230m\u5143\u7684\u6982\u7387\u662f\u591a\u5c11 \u9898\u89e3 \u4ee5\u201c\u8f93\u8f93\u8f93\u2026\u2026\u8f93\u8d62\u201d\u4e3a\u4e00\u4e2a\u5468\u671f\uff0c\u53ef\u4ee5\u8d62\u5230\u4e00\u5757\u94b1\u3002\u56e0\u800c\u9700\u8981\u7ecf\u8fc7 m \u4e2a\u8fd9\u6837\u7684\u5468\u671f\uff0c\u6709x\u5143\u53ef\u4ee5\u8f93\uff0c\u8d5a1\u5757\u7684\u6b21\u6570\u662f2^n - 1 &lt;= x\uff0cn\u5c31\u662f\u6b21\u6570\u3002\u7136\u540e\u6211\u4eec\u4e00\u5171\u6709[n, n + m - 1]\u53ef\u4ee5\u8f93\uff0c\u90a3\u4e48\u8f93x\u5143\u8d5a1\u5143\u7684\u6982\u7387\u5c31\u662f1-2^n\uff0c\u7531\u4e8em\u5f88\u5927\uff0c\u6709\u4e00\u6bb5\u533a\u95f4\u5185\u7684\u6982\u7387\u662f\u76f8\u7b49\u7684\uff0c[2^n - 1, 2^(n + 1) - 2]\u662f\u76f8\u7b49\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u4e00\u6b21\u7b97\u591a\u4e2a\u533a\u95f4\u7684\u6982\u7387 \u4ee3\u7801 #include &lt;algorithm&gt; #include &lt;bitset&gt; #include &lt;cmath&gt; #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;cstring&gt; #include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;queue&gt; #include &lt;set&gt; #include &lt;stack&gt; #include &lt;unordered_map&gt; #include &lt;unordered_set&gt; #include &lt;vector&gt; [&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":[10,5,6],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-solution","tag-10","tag-5","tag-6"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/255","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=255"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/255\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}