{"id":85,"date":"2023-03-18T20:17:00","date_gmt":"2023-03-18T12:17:00","guid":{"rendered":"https:\/\/solost.cn\/?p=85"},"modified":"2023-05-22T19:28:05","modified_gmt":"2023-05-22T11:28:05","slug":"178","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=85","title":{"rendered":"AtCoder Beginner Contest 290 &#8211; D &#8211; Marking"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image1-3.png\" alt=\"image(1).png\" title=\"image(1).png\"><\/p>\n<h2>\u9898\u76ee\u94fe\u63a5<\/h2>\n<p>[](<a href=\"https:\/\/atcoder.jp\/contests\/abc290\/tasks\/abc290_d\">https:\/\/atcoder.jp\/contests\/abc290\/tasks\/abc290_d<\/a>)<\/p>\n<h2>solution<\/h2>\n<p>\u9898\u76ee\u5927\u610f\u662f\u7ed9\u4f60\u4e00\u4e2an, d, k\uff0c\u4ece0\u5f00\u59cb\uff0c\u6bcf\u6b21\u589e\u52a0d\uff0c\u5982\u679c\u8d85\u51fan\u5c31mod n\uff0c\u5982\u679c\u8fd9\u4e2a\u70b9\u5df2\u7ecf\u7ecf\u8fc7\u8fc7\uff0c\u90a3\u4e48\u5c31+1\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u624b\u5199\u51e0\u4e2a\u6837\u4f8b\uff0c\u53d1\u73b0\u6bcf\u4e2a\u56de\u5408\u6709<code>g = n \/ gcd(n, d)<\/code>\u4e2a\uff0c\u90a3\u4e48\u6211\u4eec\u53ea\u9700\u5b9a\u4f4d\u4ed6\u5728\u7b2c\u51e0\u56de\u5408\u548c\u67d0\u56de\u5408\u7684\u7b2c\u51e0\u4e2a\u3002\u90a3\u4e48\u7b2ck\u4e2a\u5373<code>d * (k % g) % n + k \/ g<\/code><\/p>\n<pre><code class=\"lang-cpp\">#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 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;\n\nvoid solve(){\n    ll n, d, k;\n    cin &gt;&gt; n &gt;&gt; d &gt;&gt; k;\n    k--;\n    ll g = n \/ __gcd(n, d);\n    ll ans = d * (k % g) % n + k \/ g;\n    cout &lt;&lt; ans &lt;&lt; endl;\n}\nint main(){\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 [](https:\/\/atcoder.jp\/contests\/abc290\/tasks\/abc290_d) solution \u9898\u76ee\u5927\u610f\u662f\u7ed9\u4f60\u4e00\u4e2an, d, k\uff0c\u4ece0\u5f00\u59cb\uff0c\u6bcf\u6b21\u589e\u52a0d\uff0c\u5982\u679c\u8d85\u51fan\u5c31mod n\uff0c\u5982\u679c\u8fd9\u4e2a\u70b9\u5df2\u7ecf\u7ecf\u8fc7\u8fc7\uff0c\u90a3\u4e48\u5c31+1\u3002 \u6211\u4eec\u53ef\u4ee5\u624b\u5199\u51e0\u4e2a\u6837\u4f8b\uff0c\u53d1\u73b0\u6bcf\u4e2a\u56de\u5408\u6709g = n \/ gcd(n, d)\u4e2a\uff0c\u90a3\u4e48\u6211\u4eec\u53ea\u9700\u5b9a\u4f4d\u4ed6\u5728\u7b2c\u51e0\u56de\u5408\u548c\u67d0\u56de\u5408\u7684\u7b2c\u51e0\u4e2a\u3002\u90a3\u4e48\u7b2ck\u4e2a\u5373d * (k % g) % n + k \/ g #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 x first #define y second #define endl &#039;\\n&#039; #define IOS \\ ios_base::sync_with_stdio(0); \\ cin.tie(0); [&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":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-solution"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/85","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=85"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}