{"id":1074,"date":"2024-08-13T09:00:00","date_gmt":"2024-08-13T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1074"},"modified":"2024-07-14T15:37:53","modified_gmt":"2024-07-14T07:37:53","slug":"zerojudge-o231","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-o231\/","title":{"rendered":"ZeroJudge O231: Newspaper"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 11340 &#8211; Newspaper<\/h4>\n\n\n\n<p>\u65b0\u805e\u6a5f\u69cb\u6839\u64da\u4e00\u4e9b\u898f\u5247\u70ba\u6587\u7ae0\u652f\u4ed8\u5831\u916c\u3002\u6bcf\u500b\u5b57\u7b26\u90fd\u6709\u5176\u81ea\u8eab\u7684\u50f9\u503c (\u67d0\u4e9b\u5b57\u7b26\u7684\u50f9\u503c\u53ef\u80fd\u70ba\u96f6\uff09\u3002\u4f5c\u8005\u7684\u5831\u916c\u662f\u6587\u7ae0\u4e2d\u6240\u6709\u5b57\u7b26\u50f9\u503c\u7684\u7e3d\u548c\u3002\u4f60\u9700\u8981\u78ba\u5b9a\u65b0\u805e\u6a5f\u69cb\u5fc5\u9808\u652f\u4ed8\u7d66\u4f5c\u8005\u7684\u91d1\u984d\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\"><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\u5305\u542b\u4e00\u500b\u6574\u6578 N (0 &lt; N \u2264 5)\uff0c\u8868\u793a\u6e2c\u8a66\u6b21\u6578\u3002\u6bcf\u500b\u6e2c\u8a66\u63cf\u8ff0\u4e00\u500b\u6574\u6578 K (0 &lt; K \u2264 100)\uff0c\u8868\u793a\u6709\u50f9\u503c\u7684\u5b57\u7b26\u6578\u91cf\u3002\u5728\u63a5\u4e0b\u4f86\u7684 K \u884c\u4e2d\uff0c\u6709\u4e00\u500b\u652f\u4ed8\u5b57\u7b26\u53ca\u5176\u50f9\u503c\u7684\u8868\u683c (\u5b57\u7b26\u50f9\u503c\u4ee5\u7f8e\u5206\u70ba\u55ae\u4f4d\uff09\u3002\u5982\u679c\u5728\u8868\u683c\u4e2d\u627e\u4e0d\u5230\u5b57\u7b26\uff0c\u5247\u5176\u50f9\u503c\u70ba\u96f6\u3002\u63a5\u4e0b\u4f86\u662f\u4e00\u500b\u6574\u6578 M (0 &lt; M \u2264 150000)\u3002\u63a5\u4e0b\u4f86\u7684 M \u884c\u5305\u542b\u6587\u7ae0\u672c\u8eab\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u500b\u6e2c\u8a66\uff0c\u8f38\u51fa\u65b0\u805e\u6a5f\u69cb\u5fc5\u9808\u70ba\u6587\u7ae0\u652f\u4ed8\u7684\u91d1\u984d\uff0c\u683c\u5f0f\u70ba \u300cx.yy$\u300d\uff0c\u5176\u4e2d x \u662f\u6c92\u6709\u524d\u5c0e\u96f6\u7684\u7f8e\u5143\u6578\uff0cyy \u662f\u5e36\u6709\u4e00\u500b\u524d\u5c0e\u96f6\u7684\u7f8e\u5206\u6578\u3002<\/td><\/tr><tr><td>1<br>7<br>a 3<br>W 10<br>A 100<br>, 10<br>k 7<br>. 3<br>I 13<br>7<br>ACM International Collegiate Programming Contest (abbreviated<br>as ACM-ICPC or just ICPC) is an annual multi-tiered competition<br>among the universities of the world. The ICPC challenges students<br>to set ever higher standards of excellence for themselves<br>through competition that rewards team work, problem analysis,<br>and rapid software development.<br>From Wikipedia.<\/td><td>3.74$<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u4f7f\u7528 Map \u4f86\u7d00\u9304\u6bcf\u4e00\u500b\u5b57\u5143\u7684\u50f9\u503c\uff0c\u4e26\u4e14\u7528 double \u4f86\u7d00\u9304\u3002\u4f7f\u7528 getline \u4f86\u7d00\u9304\u6bcf\u4e00\u884c\u7684\u5b57\u4e32\u4e26\u4e14\u5224\u65b7\u6bcf\u4e00\u500b\u5b57\u5143\uff0c\u5982\u679c\u6c92\u6709\u5728 Map \u4e2d\u6709\u7d00\u9304\u5247\u6703\u662f 0\u3002\u56e0\u70ba\u662f\u4ee5\u7f8e\u5206\u4f86\u8a08\u7b97\u6240\u4ee5\u7b54\u6848\u8981 \/= 100\u3002\u5982\u679c\u7b54\u6848\u662f 0 \u7684\u8a71\u8981\u8f38\u51fa\u300c0.00$\u300d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=o231\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge O231: Newspaper<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><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    int N;\n    cin &gt;&gt; N;\n    for (int i = 0; i&lt;N; i++) {\n        int K, M;\n        double ans = 0;\n        cin &gt;&gt; K;\n        map&lt;char, double&gt;MAP;\n        for (int j = 0; j&lt;K; j++) {\n            char ch;\n            double money;\n            cin &gt;&gt; ch &gt;&gt; money;\n            MAP[ch] = money;\n        }\n        cin &gt;&gt; M;\n        string s;\n        getline(cin, s);\n        for (int j = 0; j&lt;M; j++) {\n            string str;\n            getline(cin, str);\n            for (int k = 0; k&lt;str.length(); k++) {\n                ans += MAP[str[k]];\n            }\n        }\n        ans \/= 100;\n        if (ans == 0) {\n            cout &lt;&lt; &quot;0.00$\\n&quot;;\n            continue;\n        }\n        cout &lt;&lt; ans &lt;&lt; &quot;$\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge O231\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 11340 &#8211; Newspaper \u65b0\u805e\u6a5f\u69cb\u6839\u64da\u4e00\u4e9b\u898f\u5247\u70ba\u6587\u7ae0\u652f\u4ed8\u5831\u916c\u3002\u6bcf\u500b\u5b57\u7b26\u90fd\u6709 [&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":[18],"tags":[14,8,11,7,9],"class_list":["post-1074","post","type-post","status-publish","format-standard","hentry","category-uva","tag-map","tag-8","tag-11","tag-7","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1074","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=1074"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1074\/revisions"}],"predecessor-version":[{"id":1076,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1074\/revisions\/1076"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=1074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=1074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=1074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}