\n\u6c42\u524d\u7f00\u548c(\u662f\u6bcf\u4e00\u4e2a\u5143\u7d20\u51fa\u73b0\u7684\u4f4d\u7f6e)<\/td>\n | 0<\/td>\n | 2<\/td>\n | 4<\/td>\n | 6<\/td>\n | 7<\/td>\n | 7<\/td>\n | 7<\/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}]}}
|