{"id":81,"date":"2023-03-16T22:26:27","date_gmt":"2023-03-16T14:26:27","guid":{"rendered":"https:\/\/solost.cn\/?p=81"},"modified":"2023-03-16T22:26:27","modified_gmt":"2023-03-16T14:26:27","slug":"172","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=81","title":{"rendered":"AtCoder Beginner Contest 293 &#8211; E &#8211; Geometric Progression"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image2-1.png\" alt=\"image(2).png\" title=\"image(2).png\"><\/p>\n<h2>\u9898\u76ee\u94fe\u63a5<\/h2>\n<p><a href=\"https:\/\/atcoder.jp\/contests\/abc293\/tasks\/abc293_e\">\u9898\u76ee\u94fe\u63a5<\/a><\/p>\n<h2>sloution<\/h2>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image3.png\" alt=\"image(3).png\" title=\"image(3).png\"><\/p>\n<p>\u8865\u5145\u4e00\u70b9\u70b9\uff0c\u4e3a\u4ec0\u4e48\u5947\u6570\u4e0d\u80fd\u7528\u6700\u540e\u4e00\u4e2a\u516c\u5f0f\u5462\uff1f\u56e0\u4e3a\u63d0\u51faA\u7684\u65f6\u5019\uff0c\u7ed3\u679c\u662f<code>f(p\/2)*xxxx<\/code>\u8fd9\u4e2a\u9700\u8981\u63d0\u51fa\u4e00\u4e2a\u5f0f\u5b50\uff0c\u6240\u4ee5\u5947\u6570\u7684\u65f6\u5019\u4e0d\u80fd\u4e8c\u5206\uff0c\u9700\u8981\u7528\u7b2c\u4e8c\u4e2a\u5f0f\u5b50\u6765\u628a\u4ed6\u518d\u8f6c\u5316\u6210\u5076\u6570\u3002<\/p>\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;vector&gt;\n\nusing namespace std;\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);\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;\nll a, x, m;\nll f[N];\n\nll qmi(ll n, ll k, ll p)\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\nll sum(ll p)\n{\n    if (p == 0)\n        return 1 % m;\n    if (p % 2) {\n        return (sum(p \/ 2) % m * (qmi(a, p \/ 2 + 1, m) + 1) % m) % m;\n    } else {\n        return (a * sum(p - 1) % m + 1) % m;\n    }\n}\n\nvoid solve()\n{\n    cin &gt;&gt; a &gt;&gt; x &gt;&gt; m;\n    ll ans = sum(x - 1);\n    cout &lt;&lt; ans &lt;&lt; endl;\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 \u9898\u76ee\u94fe\u63a5 sloution \u8865\u5145\u4e00\u70b9\u70b9\uff0c\u4e3a\u4ec0\u4e48\u5947\u6570\u4e0d\u80fd\u7528\u6700\u540e\u4e00\u4e2a\u516c\u5f0f\u5462\uff1f\u56e0\u4e3a\u63d0\u51faA\u7684\u65f6\u5019\uff0c\u7ed3\u679c\u662ff(p\/2)*xxxx\u8fd9\u4e2a\u9700\u8981\u63d0\u51fa\u4e00\u4e2a\u5f0f\u5b50\uff0c\u6240\u4ee5\u5947\u6570\u7684\u65f6\u5019\u4e0d\u80fd\u4e8c\u5206\uff0c\u9700\u8981\u7528\u7b2c\u4e8c\u4e2a\u5f0f\u5b50\u6765\u628a\u4ed6\u518d\u8f6c\u5316\u6210\u5076\u6570\u3002 #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;vector&gt; using namespace std; #define x first #define y second #define endl &#039;\\n&#039; #define IOS \\ ios_base::sync_with_stdio(0); \\ cin.tie(0); \\ cout.tie(0); typedef long long [&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":[36,10,37],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-solution","tag-36","tag-10","tag-37"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/81","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=81"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}