{"id":476,"date":"2023-09-05T20:26:58","date_gmt":"2023-09-05T12:26:58","guid":{"rendered":"http:\/\/ggapa.net:81\/?p=476"},"modified":"2023-11-09T21:42:23","modified_gmt":"2023-11-09T13:42:23","slug":"9-5-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0csp-s1","status":"publish","type":"post","link":"http:\/\/ggapa.net:81\/2023\/09\/05\/9-5-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0csp-s1\/","title":{"rendered":"\u57fa\u6570\u6392\u5e8f"},"content":{"rendered":"

\u4eca\u5929\u665a\u4e0a6:30-8:30\u7531\u6210\u90fd\u4e03\u4e2d\u6559\u7ec3\u8bb2\u89e3CSP 2022-S1<\/p>\n

\u57fa\u6570\u6392\u5e8f<\/p>\n

\u9700\u8981\u5904\u7406\u7684\u6570\u5b57
\n24\u300121\u3001123\u3001321\u3001122\u300123\u300132<\/p>\n\n\n\n\n\n\n
\u7c7b\u578b<\/th>\n0<\/th>\n1<\/th>\n2<\/th>\n3<\/th>\n4<\/th>\n5<\/th>\n6<\/th>\n<\/tr>\n<\/thead>\n
\u4e2a\u4f4d\u8ba1\u6570\u5668<\/td>\n0<\/td>\n2<\/td>\n2<\/td>\n2<\/td>\n1<\/td>\n0<\/td>\n0<\/td>\n<\/tr>\n
\u6c42\u524d\u7f00\u548c(\u662f\u6bcf\u4e00\u4e2a\u5143\u7d20\u51fa\u73b0\u7684\u4f4d\u7f6e)<\/td>\n0<\/td>\n2<\/td>\n4<\/td>\n6<\/td>\n7<\/td>\n7<\/td>\n7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5230\u8fd9\u4e00\u6b65\u4e4b\u540e\u6bcf\u653e\u5165\u4e00\u4e2a\u5143\u7d20\u4e4b\u540e\u5c31\u5427\u5bf9\u5e94\u6570\u5b57$ -1 $<\/p>\n

\n#include <iostream>\n\nusing namespace std;\n\nconst int MAXN = 105;\n\nint n, m, k, val[MAXN];\nint temp[MAXN], cnt[MAXN];\n\n void init() \n {\n     cin >> n >> k;\n     for (int i = 0; i < n; i++) cin >> val[i];\n     int maximum = val[0];\n     for (int i = 1; i < n; i++)\n         if (val[i] > maximum) maximum = val[i];\n     m = 1;\n     while (maximum >= k) {\n         maximum \/= k;\n         m++;\n     }\n }\n\n void solve() \n {\n     int base = 1;\n     for (int i = 0; i < m; i++) {\n         for (int j = 0; j < k; j++) cnt[j] = 0;\/\/\u8ba1\u6570\u5668\u6e050\n         for (int j = 0; j < n; j++) cnt[val[j] \/ base % k]++;\/\/\u8ba1\u7b97\u8fdb\u5236\u7684\u4f4d\u6570\uff0c\u5728\u8fd9\u91cc\u8ba1\u7b97\u4e0b\u6807\n         for (int j = 1; j < k; j++) cnt[j] += cnt[j - 1]; \/\/\u8ba1\u7b97\u524d\u7f00\u548c\n         for (int j = n - 1; j >= 0; j--) {\n             temp[cnt[val[j] \/ base % k]\/*\u5bf9\u5e94\u7684\u4f4d\u7f6e*\/ - 1\/*\u4ece0\u5f00\u59cb\u8bb0\u5f55\u6240\u4ee5\u8bf4\u8981-1*\/] = val[j];\/\/\u5728\u8fd9\u4e2a\u5730\u65b9\u5012\u7740\u626b\u63cf\n             cnt[val[j] \/ base % k]--;\/*\u8fd9\u91cc\u5373\u4e3a\u57fa\u6570\u6392\u5e8f\u7684-1\u64cd\u4f5c*\/\n         }\n         for (int j = 0; j < n; j++) val[i] = temp[j];\/*\u628a\u6570\u7ec4\u5bfc\u5165*\/\n         base *= k;\/*\u589e\u52a0base\uff0c\u8f6c\u6362\u4e3a\u8fdb\u4f4d\u64cd\u4f5c\uff0c\u8ba1\u7b97\u4e0b\u4e00\u4f4d*\/\n     }\n }\n\n int main() \n {\n     init();\n     solve();\n     for (int i = 0; i < n; i++) cout << val[i] << ;\n     cout << endl;\n     return 0;\n```cpp<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

\u4eca\u5929\u665a\u4e0a6:30-8:30\u7531\u6210\u90fd\u4e03\u4e2d\u6559\u7ec3\u8bb2\u89e3CSP 2022-S1 \u57fa\u6570\u6392\u5e8f \u9700\u8981\u5904\u7406\u7684\u6570\u5b57 24\u300121\u300112 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/476"}],"collection":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/comments?post=476"}],"version-history":[{"count":2,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/476\/revisions"}],"predecessor-version":[{"id":841,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/476\/revisions\/841"}],"wp:attachment":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/media?parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/categories?post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/tags?post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}