{"id":204,"date":"2024-04-26T18:44:21","date_gmt":"2024-04-26T10:44:21","guid":{"rendered":"https:\/\/seanxd.com\/?p=204"},"modified":"2024-04-26T18:44:23","modified_gmt":"2024-04-26T10:44:23","slug":"zerojudge-e973","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-e973\/","title":{"rendered":"ZeroJudge E973: \u6eff\u610f\u5ea6\u8abf\u67e5 (Survey of Satisfaction)"},"content":{"rendered":"\n\n\n<p class=\"\">\u5c08\u9577\u7d71\u8a08\u5b78\u7684\u6797\u7f8a\u8001\u5e2b\u6700\u8fd1\u51fa\u4e86\u4e00\u500b\u984c\u76ee\uff0c\u8981\u7b97\u554f\u5377\u8abf\u67e5\u6eff\u610f\u5ea6 0\uff5e9 \u7684\u51fa\u73fe\u6b21\u6578\uff0c\u9032\u800c\u63a2\u8a0e\u4e0d\u540c\u884c\u92b7\u7b56\u7565\u7684\u5236\u5b9a\u65b9\u91dd\u3002<\/p>\n\n\n\n<p class=\"\"><strong>\u4f8b\u5982\uff1a<\/strong>\u300c11221812\u300d \u8868\u793a\u6eff\u610f\u5ea6 1 \u51fa\u73fe 4 \u6b21\uff0c\u6eff\u610f\u5ea6 2 \u51fa\u73fe 3 \u6b21\uff0c\u6eff\u610f\u5ea6 8 \u51fa\u73fe 1 \u6b21\u3002<\/p>\n\n\n\n<p class=\"\">\u6587\u6587\u5c0f\u59d0\u770b\u5230\u4e00\u6574\u4e32\u6578\u5b57\u7684\u6642\u5019\u7e3d\u662f\u6703\u982d\u75db\uff0c\u56e0\u6b64\u60f3\u8981\u8ffd\u6c42\u6587\u6587\u5c0f\u59d0\u7684\u5b85\u7537\u5de5\u7a0b\u5e2b\u6c7a\u5b9a\u904b\u7528\u7a0b\u5f0f\u8a2d\u8a08\u8ab2\u6240\u5b78\uff0c\u5e6b\u52a9\u5979\u9806\u5229\u7b97\u51fa\u554f\u5377\u5404\u6eff\u610f\u5ea6\u51fa\u73fe\u7684\u6b21\u6578\uff0c\u6210\u529f\u7d04\u5979\u51fa\u53bb\u73a9\uff01<strong>\u7d66\u5b9a\u4e00\u6578\u5b57\uff0c\u4ee3\u8868\u554f\u5377\u5404\u984c\u7684\u8abf\u67e5\u6eff\u610f\u5ea6<\/strong>\uff0c\u7a0b\u5f0f\u61c9\u7b97\u51fa\u5404\u6eff\u610f\u51fa\u73fe\u7684\u6b21\u6578\uff0c\u6700\u5f8c<strong>\u4f9d\u51fa\u73fe\u6b21\u6578\u7531\u5927\u81f3\u5c0f\u6392\u5e8f<\/strong>\u4e26\u8f38\u51fa\u6eff\u610f\u5ea6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u7b2c\u4e00\u884c\u6709\u4e00\u500b\u6b63\u6574\u6578 N (1 &lt;= N &lt;= 2<sup>63<\/sup> \u2212 1)\uff0c\u4ee3\u8868\u8a72\u554f\u5377\u5404\u984c\u7684\u6eff\u610f\u5ea6\u3002\uff08\u82e5\u4ee5 long long int \u578b\u614b\u8b8a\u6578\u5132\u5b58 N\uff0c\u4ee5 scanf() \u8b80\u5165\u6642\uff0c\u8acb\u4ee5 %lld \u4f5c\u70ba\u683c\u5f0f\u6307\u5b9a\u5b57\u4e32\u3002\uff09<\/td><td>\u5c0d\u65bc\u6bcf\u7b46\u6e2c\u8cc7\u8f38\u51fa K (1 &lt;= K &lt;= 10) \u500b\u6eff\u610f\u5ea6\u503c\uff0cK \u4ee3\u8868 N \u4e2d 0 ~ 9 \u6709\u51fa\u73fe\u904e\u7684\u6eff\u610f\u5ea6\u503c\u500b\u6578\u3002<strong>\u7531\u5de6\u81f3\u53f3\u7684\u6eff\u610f\u5ea6\u51fa\u73fe\u6b21\u6578\u7531\u9ad8\u81f3\u4f4e\uff0c\u6b21\u6578\u4e00\u6a23\u5247\u8f38\u51fa\u6eff\u610f\u5ea6\u503c\u5c0f\u8005<\/strong>\u3002\u6eff\u610f\u5ea6\u503c\u5f7c\u6b64\u9593\u4ee5\u7a7a\u767d\u9593\u9694\u3002<\/td><\/tr><tr><td>2425264426558<\/td><td>2  4  5  6  8<\/td><\/tr><tr><td>1234567891011121314<\/td><td>1  2  3  4  0  5  6  7  8  9<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u4f7f\u7528<strong>\u300cEOF\u300d\u6536\u300c\u5b57\u5143\u300d<\/strong>\u7684\u65b9\u5f0f\u6536\u8cc7\u6599\uff0c\u9019\u6a23\u5b50\u4e00\u6b21\u53ea\u6703\u6536\u4e00\u500b\u5b57\u5143\u4e0d\u9700\u8981\u4f7f\u7528long long int\u6216\u662fstring+stringstream\u4f86\u8655\u7406\u8cc7\u6599\uff0c\u7576\u6536\u5230\u5b57\u5143\u6642<strong>\u4f7f\u7528 Map \u5c07\u8a72\u6578\u5b57\u51fa\u73fe\u7684\u6b21\u6578 +1<\/strong>\u3002\u63a5\u4e0b\u4f86\u53ef\u4ee5\u4f7f\u7528 <strong>while (true)<\/strong> \u8ff4\u5708\u4f86\u505a\u8f38\u51fa\u5224\u5b9a\u3002\u6bcf\u6b21while\u8ff4\u5708\u4e2d\u8dd1\u4e00\u500bFor\u8ff4\u5708\u4f86\u78ba\u8a8d<strong>\u76ee\u524d Map \u4e2d\u6700\u5927\u503c<\/strong>\u7684\u6578\u5b57\u70ba\u591a\u5c11\uff0c\u4e26\u5c07\u5176\u8f38\u51fa\u4e14\u628a<strong>\u8a72\u6578\u5b57\u7684MAP\u503c\u8a2d\u70ba0<\/strong>\u3002\u7576\u6240\u6709\u5927\u65bc0\u7684MAP\u503c\u90fd\u8f38\u51fa\u904e\u4e4b\u5f8c\u5c31\u5c07 While \u8ff4\u5708 break \u6389\uff0c\u6700\u5f8c\u63db\u884c\u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=e973\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge E973: \u6eff\u610f\u5ea6\u8abf\u67e5 (Survey of Satisfaction)<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;map&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    map&lt;int, int&gt;MAP;\n    char ch;\n    while (cin &gt;&gt; ch)\n    {\n        MAP[int(ch - &#39;0&#39;)]++;\n    }\n    while (true)\n    {\n        int max = -999;\n        int max_num;\n        for (int i = 0; i&lt;10; i++)\n        {\n            if (MAP[i] &gt; max)\n            {\n                max = MAP[i];\n                max_num = i;\n            }\n        }\n        if (max &lt;= 0)\n        {\n            break;\n        }\n        else\n        {\n            cout &lt;&lt; max_num &lt;&lt; &quot; &quot;;\n            MAP[max_num] = 0;\n        }\n    }\n    cout &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge E973\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5c08\u9577\u7d71\u8a08\u5b78\u7684\u6797\u7f8a\u8001\u5e2b\u6700\u8fd1\u51fa\u4e86\u4e00\u500b\u984c\u76ee\uff0c\u8981\u7b97\u554f\u5377\u8abf\u67e5\u6eff\u610f\u5ea6 0\uff5e9 \u7684\u51fa\u73fe\u6b21\u6578\uff0c\u9032\u800c\u63a2\u8a0e\u4e0d\u540c\u884c\u92b7\u7b56\u7565\u7684\u5236\u5b9a\u65b9\u91dd\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[25],"tags":[14,8,11,9],"class_list":["post-204","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-map","tag-8","tag-11","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=204"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/204\/revisions"}],"predecessor-version":[{"id":205,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/204\/revisions\/205"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}