{"id":1270,"date":"2022-06-04T09:59:26","date_gmt":"2022-06-04T01:59:26","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=1270"},"modified":"2022-06-04T09:59:26","modified_gmt":"2022-06-04T01:59:26","slug":"hj88-%e6%89%91%e5%85%8b%e7%89%8c%e5%a4%a7%e5%b0%8fhashmap","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2022\/06\/04\/hj88-%e6%89%91%e5%85%8b%e7%89%8c%e5%a4%a7%e5%b0%8fhashmap\/","title":{"rendered":"HJ88 \u6251\u514b\u724c\u5927\u5c0fHashMap"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p>\u8f93\u5165\u4e24\u624b\u724c\uff0c\u4e24\u624b\u724c\u4e4b\u95f4\u7528&#8221;-&#8220;\u8fde\u63a5\uff0c\u6bcf\u624b\u724c\u7684\u6bcf\u5f20\u724c\u4ee5\u7a7a\u683c\u5206\u9694\uff0c&#8221;-&#8220;\u4e24\u8fb9\u6ca1\u6709\u7a7a\u683c\uff0c\u5982&nbsp;4&nbsp;4&nbsp;4&nbsp;4-joker&nbsp;JOKER\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p>\u8f93\u51fa\u4e24\u624b\u724c\u4e2d\u8f83\u5927\u7684\u90a3\u624b\uff0c\u4e0d\u542b\u8fde\u63a5\u7b26\uff0c\u6251\u514b\u724c\u987a\u5e8f\u4e0d\u53d8\uff0c\u4ecd\u4ee5\u7a7a\u683c\u9694\u5f00\uff1b\u5982\u679c\u4e0d\u5b58\u5728\u6bd4\u8f83\u5173\u7cfb\u5219\u8f93\u51faERROR\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b1<\/h2>\n\n\n\n<p>\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">4 4 4 4-joker JOKER\n<\/pre>\n\n\n\n<p>\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">joker JOKER<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*;\n\n\npublic class Main{\n    public static void main(String&#91;] args){\n        Scanner scan = new Scanner(System.in);\n        String input = scan.nextLine();\n        String&#91;] cards = input.trim().split(\"-\");\n        String output = max(cards&#91;0], cards&#91;1]);\n        System.out.println(output);\n    }\n    \n    public static String max(String cards1, String cards2){\n        Map&lt;String,Integer> map = new HashMap&lt;String, Integer>(){\n            {\n                put(\"3\",3);\n                put(\"4\",4);\n                put(\"5\",5);\n                put(\"6\",6);\n                put(\"7\",7);\n                put(\"8\",8);\n                put(\"9\",9);\n                put(\"10\",10);\n                put(\"J\",11);\n                put(\"Q\",12);\n                put(\"K\",13);\n                put(\"A\",14);\n                put(\"2\",15);\n                put(\"joker\",16);\n                put(\"JOKER\",17);\n            }\n        }; \n        String&#91;] c1 = cards1.split(\" \");\n        String&#91;] c2 = cards2.split(\" \");\n      \/\/\u738b\u70b8\n        if(cards1.equals(\"joker JOKER\")){\n            return cards1;\n        }\n        else if(cards2.equals(\"joker JOKER\")){\n            return cards2;\n        }\n      \/\/\u90fd\u662f\u70b8\u5f39\n        else if(c1.length == c2.length &amp;&amp; c1.length == 4){\n            return map.get(c1&#91;0]) > map.get(c2&#91;0]) ? cards1 : cards2;      \n        }\n      \/\/\u6709\u4e00\u4e2a\u662f\u70b8\u5f39\n        else if(c1.length == 4){\n            return cards1;      \n        }      \n        else if(c2.length == 4){\n            return cards2;\n        }\n      \/\/\u5176\u4ed6\u7684\n        else if(c1.length == c2.length){\n            return map.get(c1&#91;0]) > map.get(c2&#91;0]) ? cards1 : cards2; \n        }\n      \/\/\u65e0\u6cd5\u6bd4\u8f83\n        else {\n            return \"ERROR\";\n        }                \n    }\n}\n\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u9898\u89e3 | #\u6251\u514b\u724c\u5927\u5c0f#<\/h2>\n\n\n\n<p>\u9898\u76ee\u91cc\u7684\u5355\u6392\u5e94\u8be5\u5c31\u662f\u4e00\u5f20\u724c\uff0c\u8fd9\u79cd\u7684\u8bdd\u53ea\u7528\u6bd4\u8f83\u957f\u5ea6\u548c\u6700\u4f4e\u4f4d\uff0c\u6bd4\u8f83\u7b80\u5355\u76f4\u63a5\u3002\u6211\u4e00\u5f00\u59cb\u60f3\u7684\u5355\u6392\u662f257\u8fd9\u79cd\uff0c\u8fd9\u79cd\u5f88\u9ebb\u70e6\u3002 anyway\uff0c\u6839\u636e\u9898\u76ee\u7684\u610f\u601d\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u662f\u738b\u70b8\uff0c\u76f4\u63a5\u8f93\u51fa\u3002\u4e0d\u662f\u5219\u6bd4\u8f83\u4e24\u526f\u724c\u7684\u6570\u91cf\u3002<\/li><li>\u5982\u679c\u90fd\u4e3a4\uff0c\u5219\u662f\u4e24\u5e45\u70b8\uff0c\u8f93\u51fa\u8f83\u5927\u7684\u4e00\u4e2a\u3002<\/li><li>\u5982\u679c\u53ea\u6709\u5176\u4e2d\u4e00\u4e2a\u662f4\uff0c\u5219\u8f93\u51fa\u8fd9\u4e2a\u3002<\/li><li>\u5982\u679c\u90fd\u4e0d\u662f\u70b8\uff0c\u5219\u76f4\u63a5\u6bd4\u8f83\u6700\u5c0f\u4f4d<\/li><li>\u65e0\u6cd5\u6bd4\u8f83\uff0cERROR<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u8f93\u5165\u63cf\u8ff0\uff1a \u8f93\u5165\u4e24\u624b\u724c\uff0c\u4e24\u624b\u724c\u4e4b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1257,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[],"class_list":["post-1270","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-4"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=1270"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1270\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media\/1257"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=1270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=1270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=1270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}