{"id":1105,"date":"2024-08-17T09:00:00","date_gmt":"2024-08-17T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1105"},"modified":"2024-07-15T17:14:54","modified_gmt":"2024-07-15T09:14:54","slug":"zerojudge-o087","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-o087\/","title":{"rendered":"ZeroJudge O087: Prince's Name"},"content":{"rendered":"\n\n\n<p>\u6700\u8fd1\u738b\u5b50\u8a95\u751f\u4e86\uff0c\u570b\u738b\u60f3\u8981\u70ba\u4ed6\u53d6\u500b\u5b8c\u7f8e\u7684\u540d\u5b57\u3002\u4f46\u662f\u5982\u679c\u53ea\u9760\u81ea\u5df1\u60f3\u5be6\u5728\u662f\u5f88\u96e3\u60f3\u5230\u4e0d\u932f\u7684\u540d\u5b57\uff0c\u65bc\u662f\u570b\u738b\u6c7a\u5b9a\u8acb\u4eba\u6c11\u6295\u7a3f\u540d\u5b57\u4f86\u7576\u4f5c\u53c3\u8003\u3002<\/p>\n\n\n\n<p>\u7531\u65bc\u5168\u570b\u7684\u4eba\u6c11\u5be6\u5728\u592a\u591a\u4e86\uff0c\u5230\u6642\u5019\u6295\u7a3f\u7684\u6578\u91cf\u53ef\u80fd\u6703\u591a\u5230\u96e3\u4ee5\u770b\u5b8c\uff0c\u6240\u4ee5\u570b\u738b\u60f3\u8acb\u4f60\u5beb\u500b\u7a0b\u5f0f\u5e6b\u5e6b\u4ed6\u3002\u570b\u738b\u7d66\u4e86\u4f60\u4e00\u500b Python \u51fd\u6578 (\u5982\u4e0b)\uff0c\u9019\u500b\u51fd\u6578\u80fd\u5920\u5e6b\u4f60\u8a08\u7b97\u4e00\u500b\u540d\u5b57\u5728\u570b\u738b\u7684\u5fc3\u4e2d\u80fd\u5920\u5f97\u5230\u5e7e\u5206\uff0c\u8acb\u4f60\u5229\u7528\u9019\u500b\u51fd\u6578\u4f86\u5c07\u4eba\u6c11\u6295\u7a3f\u7684\u540d\u5b57\u6392\u5e8f\u597d\u3002(\u8acb\u6309\u7167\u5728\u570b\u738b\u5fc3\u4e2d\u7684\u5206\u6578\u7531\u5c0f\u5230\u5927\u6392\u5e8f\uff0c\u5982\u679c\u5169\u500b\u540d\u5b57\u540c\u5206\u5247\u5148\u6295\u7a3f\u7684\u653e\u5728\u524d\u9762)<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u570b\u738b\u7d66\u4f60\u7684 Python \u51fd\u6578\uff0c\u7576\u4f60\u628a\u4e00\u500b\u540d\u5b57 (\u5b57\u4e32) \u4e1f\u7d66\u5b83\uff0c\u5b83\u6703\u70ba\u4f60\u8a08\u7b97\u51fa\u4e00\u500b 0\uff5e100 \u7684\u5206\u6578\uff0c\u4ee3\u8868\u9019\u500b\u540d\u5b57\u5728\u570b\u738b\u5fc3\u4e2d\u80fd\u5920\u5f97\u5230\u5e7e\u5206\u3002\u8acb\u6ce8\u610f\uff0c\u5982\u679c\u4f60\u7d66\u9019\u500b\u51fd\u6578\u7684\u8cc7\u6599\u4e26\u4e0d\u662f\u4e00\u500b\u5b57\u4e32\uff0c\u90a3\u8a08\u7b97\u51fa\u4f86\u7684\u5206\u6578\u5c07\u6703\u662f -1\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>def Evaluate(Name: str):                       \n    if(type(Name) != str):                     \n        return -1                              \n                                               \n    Score = 0                                  \n    NameLen = len(Name)                        \n                                               \n    for i in range(NameLen):                   \n        CharCode = ord(Name[i])                \n        Score += ((CharCode * 1123) % 1002)    \n                                               \n        while (CharCode &gt; 0):                  \n            Score += (CharCode % 10)           \n            CharCode = (CharCode \/\/ 10)        \n                                               \n    return (Score % 101)                       <\/code><\/pre><\/div>\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>\u8f38\u5165\u7684\u7b2c\u4e00\u884c\u662f\u4e00\u500b\u6b63\u6574\u6578 N\uff0c\u4ee3\u8868\u7e3d\u5171\u52df\u96c6\u4e86 N \u500b\u540d\u5b57\u3002(N \u2266 600)<br>\u63a5\u4e0b\u4f86 N \u884c\uff0c\u6bcf\u4e00\u884c\u6703\u6709\u4e00\u500b\u7531\u5b57\u6bcd\u6240\u7d44\u6210\u7684\u5b57\u4e32\uff0c\u4ee3\u8868\u4e00\u500b\u540d\u5b57\u3002(\u540d\u5b57\u9577\u5ea6\u70ba 15 \u500b\u5b57\u4ee5\u5167)<\/td><td>\u8acb\u4f9d\u7167\u9019\u4e9b\u540d\u5b57\u5728\u570b\u738b\u5fc3\u4e2d\u7684\u5206\u6578\u6392\u5e8f\u4e4b\u5f8c\uff0c\u6bcf\u4e00\u884c\u8f38\u51fa\u4e00\u500b\u540d\u5b57\u4ee5\u53ca\u9019\u500b\u540d\u5b57\u7684\u5206\u6578(\u7528\u7a7a\u767d\u9694\u958b)\uff0c\u6240\u4ee5\u8f38\u51fa\u7d50\u679c\u7e3d\u5171\u6703\u6709 N \u884c\u3002<\/td><\/tr><tr><td>5<br>Megumin<br>GawrGura<br>chunchunmaru<br>BeggarCannon<br>Kazuma<\/td><td>Megumin 17<br>BeggarCannon 19<br>GawrGura 50<br>Kazuma 56<br>chunchunmaru 88<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge O087 \u7bc4\u4f8b\u6e2c\u8cc7<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e0a\u8ff0\u7684\u51fd\u5f0f\u8f49\u6210 C++ \u7684\u6a23\u5b50\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>int Evaluate(const string str) {\n    int Score = 0;\n    for (int i = 0; i&lt;str.length(); i++) {\n        int CharCode = float(str[i]);\n        Score += CharCode * 1123 % 1002;\n        while (CharCode &gt; 0) {\n            Score += CharCode % 10;\n            CharCode \/= 10;\n        }\n    }\n    return Score % 101;\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u4f7f\u7528 Pair \u4f86\u9032\u884c\u6536\u8cc7\u6599\u7684\u52d5\u4f5c\uff0c\u5c07\u540d\u5b57\u9032\u884c\u8f38\u5165\u4e4b\u5f8c\u5224\u65b7\u5176\u5206\u6578\uff0c\u4e26\u4e14\u5ba3\u544a\u4e00\u500b Pair&lt;int, int> \u9663\u5217\uff0c\u5c07\u5206\u6578\u4f5c\u70ba Pair.first\uff0c\u7b2c\u5e7e\u500b\u6536\u9032\u4f86\u7684\u653e\u5728 Pair.second\u3002\u5ba3\u544a\u4e00\u500b\u5b57\u4e32\u9663\u5217\u4e26\u5c07\u5b57\u4e32\u5b58\u5728\u9019\u88e1\u3002<\/p>\n\n\n\n<p>\u4e4b\u5f8c\u76f4\u63a5 Sort \u9019\u500b\u9663\u5217\uff0c\u56e0\u70ba\u6709\u5b58\u9032\u4f86\u7684\u9806\u5e8f\u6240\u4ee5\u5148\u9032\u4f86\u7684\u4eba\u6703\u6392\u5728\u524d\u9762\u3002\u5229\u7528 Pair.second \u4f86\u8f38\u51fa\u5b57\u4e32\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=o087\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge O087: \u738b\u5b50\u7684\u540d\u5b57<\/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;algorithm&gt;\nusing namespace std;\n\nint Evaluate(const string str) {\n    int Score = 0;\n    for (int i = 0; i&lt;str.length(); i++) {\n        int CharCode = float(str[i]);\n        Score += CharCode * 1123 % 1002;\n        while (CharCode &gt; 0) {\n            Score += CharCode % 10;\n            CharCode \/= 10;\n        }\n    }\n    return Score % 101;\n}\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    pair&lt;int, int&gt; score[1000] = {};\n    string name[1000] = {};\n    for (int i = 0; i&lt;N; i++) {\n        cin &gt;&gt; name[i];\n        score[i].first = Evaluate(name[i]);\n        score[i].second = i;\n    }\n    sort(score, score+N);\n    for (int i = 0; i&lt;N; i++) {\n        cout &lt;&lt; name[score[i].second] &lt;&lt; &quot; &quot; &lt;&lt; score[i].first &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge O087\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u738b\u5b50\u8a95\u751f\u4e86\uff0c\u570b\u738b\u60f3\u8981\u70ba\u4ed6\u53d6\u500b\u5b8c\u7f8e\u7684\u540d\u5b57\u3002\u4f46\u662f\u5982\u679c\u53ea\u9760\u81ea\u5df1\u60f3\u5be6\u5728\u662f\u5f88\u96e3\u60f3\u5230\u4e0d\u932f\u7684\u540d\u5b57\uff0c\u65bc\u662f\u570b\u738b\u6c7a\u5b9a\u8acb\u4eba\u6c11\u6295\u7a3f [&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":[6],"tags":[23,20,8,11,19,9],"class_list":["post-1105","post","type-post","status-publish","format-standard","hentry","category-6","tag-pair","tag-20","tag-8","tag-11","tag-19","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=1105"}],"version-history":[{"count":3,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1105\/revisions"}],"predecessor-version":[{"id":1108,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1105\/revisions\/1108"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=1105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=1105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=1105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}