{"id":83,"date":"2023-03-18T20:01:55","date_gmt":"2023-03-18T12:01:55","guid":{"rendered":"https:\/\/solost.cn\/?p=83"},"modified":"2023-03-18T20:01:55","modified_gmt":"2023-03-18T12:01:55","slug":"174","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=83","title":{"rendered":"\u56db\u5ddd\u5927\u5b66\u7b2c\u4e94\u5c4aSCUACM\u65b0\u751f\u8d5b\uff08\u540c\u6b65\u8d5b\uff09- K &#8211; \u7b80\u5355\u9898"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image-9.png\" alt=\"image.png\" title=\"image.png\"><\/p>\n<h2>\u9898\u76ee\u94fe\u63a5<\/h2>\n<p><a href=\"https:\/\/ac.nowcoder.com\/acm\/contest\/53417\/K\">\u9898\u76ee\u94fe\u63a5<\/a><\/p>\n<h2>solution<\/h2>\n<p>\u901a\u8fc7\u62c6\u89e3\u516c\u5f0f\uff0c\u53ef\u4ee5\u5f97\u51fa\u5f53<code>a[i] &lt; x<\/code>\u65f6\u5019\uff0c\u8fdb\u884c\u516c\u5f0f\u53d8\u6362\u540e\u4e5f\u8fd8\u662f\u539f\u6765\u7684\u6570\u503c\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u7528\u5904\u7406\u5927\u4e8e\u7b49\u4e8e\u7684\u60c5\u51b5\u3002\u9996\u5148\u60f3\u5230\u7684\u65b9\u6cd5\u662f\u641c\u7d22\u3002<\/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;\nll ans = 1e18, x, n, a[30];\nvector&lt;int&gt; v;\nvoid dfs(ll last, ll x)\n{\n    if (last &gt;= v.size() || (last &lt; v.size() &amp;&amp; x &gt; v[v.size() - 1])) {\n        ans = min(x, ans);\n        return;\n    }\n  \n    for (int i = last; i &lt; v.size(); i++) {\n        if (v[i] &gt;= x) {\n            dfs(i + 1, x + (v[i] \/ x) * (v[i] + v[i] % x));\n        }\n    }\n}\n\nvoid solve()\n{\n    cin &gt;&gt; n;\n    for (int i = 1; i &lt;= n; i++) {\n        cin &gt;&gt; a[i];\n    }\n    cin &gt;&gt; x;\n    for (int i = 1; i &lt;= n; i++) {\n        if (a[i] &gt;= x) {\n            v.emplace_back(a[i]);\n        }\n    }\n    sort(v.begin(), v.end());\n    dfs(0, x);\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 \u9898\u76ee\u94fe\u63a5 solution \u901a\u8fc7\u62c6\u89e3\u516c\u5f0f\uff0c\u53ef\u4ee5\u5f97\u51fa\u5f53a[i] &lt; x\u65f6\u5019\uff0c\u8fdb\u884c\u516c\u5f0f\u53d8\u6362\u540e\u4e5f\u8fd8\u662f\u539f\u6765\u7684\u6570\u503c\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u7528\u5904\u7406\u5927\u4e8e\u7b49\u4e8e\u7684\u60c5\u51b5\u3002\u9996\u5148\u60f3\u5230\u7684\u65b9\u6cd5\u662f\u641c\u7d22\u3002 #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); \\ cout.tie(0); typedef long long ll; typedef pair&lt;int,int&gt; PII; typedef unsigned long long ull; const int INF [&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":[24],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-solution","tag-dfs"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/83","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=83"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}