<\/div>\n\n\n\n
\u82f1\u6587\u539f\u6587\u5982\u4e0b<\/strong><\/p>\n\n\n\nThose days, many boys use beautiful girls’ photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network.<\/p>\n\n\n\n
But yesterday, he came to see “her” in the real world and found out “she” is actually a very strong man! Our hero is very sad and he is too tired to love again now. So he came up with a way to recognize users’ genders by their user names.<\/p>\n\n\n\n
This is his method: if the number of distinct characters in one’s user name is odd, then he is a male, otherwise she is a female. You are given the string that denotes the user name, please help our hero to determine the gender of this user by his method.<\/p>\n\n\n\n
<\/div>\n\n\n\n
\u4e2d\u6587\u7ffb\u8b6f<\/strong><\/p>\n\n\n\n\u90a3\u4e9b\u65e5\u5b50\uff0c\u8a31\u591a\u7537\u751f\u4f7f\u7528\u6f02\u4eae\u7684\u5973\u751f\u7684\u7167\u7247\u4f5c\u70ba\u4ed6\u5011\u8ad6\u58c7\u7684\u982d\u50cf\uff0c\u6240\u4ee5\u9019\u4f7f\u5f97\u7b2c\u4e00\u773c\u5f88\u96e3\u5206\u8fa8\u4f7f\u7528\u8005\u7684\u6027\u5225\u3002\u53bb\u5e74\uff0c\u6211\u5011\u7684\u4e3b\u89d2\u9032\u5165\u4e86\u4e00\u500b\u8ad6\u58c7\u4e26\u8207\u4e00\u4f4d\u7f8e\u5973(\u4ed6\u9019\u9ebc\u4ee5\u70ba)\u6709\u4e00\u6b21\u7f8e\u597d\u7684\u804a\u5929\u3002\u518d\u7d93\u904e\u4e00\u6bb5\u6642\u9593\u983b\u7e41\u7684\u806f\u7d61\u4e0b\uff0c\u4ed6\u5011\u6700\u7d42\u6210\u70ba\u4e86\u4e00\u5c0d\u7db2\u8def\u4e0a\u7684\u60c5\u4fb6\u3002<\/p>\n\n\n\n
\u4f46\u5728\u6628\u5929\u7684\u6642\u5019\uff0c\u4ed6\u8dd1\u53bb\u73fe\u5be6\u4e16\u754c\u898b\u300c\u5979\u300d\uff0c\u537b\u767c\u73fe\u300c\u5979\u300d\u5176\u5be6\u662f\u4e00\u500b\u5f88\u58ef\u7684\u7537\u6027! \u6211\u5011\u7684\u7537\u4e3b\u89d2\u975e\u5e38\u96e3\u904e\u800c\u4e14\u4ed6\u6709\u597d\u4e00\u6bb5\u65e5\u5b50\u90fd\u4e0d\u60f3\u5728\u611b\u4e86\u3002\u56e0\u6b64\uff0c\u4ed6\u60f3\u51fa\u4e86\u4e00\u7a2e\u65b9\u5f0f\u4f86\u8fa8\u5225\u4f7f\u7528\u8005\u7684\u6027\u5225 – \u4ed6\u5011\u7684\u4f7f\u7528\u8005\u540d\u7a31\u3002<\/p>\n\n\n\n
\u9019\u88e1\u662f\u4ed6\u7684\u65b9\u6cd5 : \u8981\u662f\u4e00\u500b\u4f7f\u7528\u8005\u540d\u7a31\u552f\u4e00\u7684\u5b57\u6bcd\u662f\u5947\u6578\uff0c\u90a3\u4ed6\u5c31\u662f\u7537\u751f\uff0c\u53cd\u4e4b\u5247\u70ba\u5973\u751f\u3002\u6703\u7d66\u4e88\u4f60\u4e00\u500b\u5b57\u4e32\u4ee3\u8868\u4f7f\u7528\u8005\u7684\u540d\u7a31\uff0c\u8acb\u5e6b\u52a9\u6211\u5011\u7684\u4e3b\u89d2\u4f86\u6c7a\u5b9a\u8a72\u4f7f\u7528\u8005\u7684\u6027\u5225 (\u7528\u4ed6\u7684\u65b9\u5f0f)\u3002<\/p>\n\n\n\n
<\/div>\n\n\n\n
\u8f38\u5165<\/strong><\/p>\n\n\n\nThe first line contains a non-empty string, that contains only lowercase English letters \u2014 the user name. This string contains at most 100 letters.<\/p>\n\n\n\n
\u7b2c\u4e00\u884c\u5305\u542b\u4e86\u4e00\u500b\u975e\u7a7a\u7684\u5b57\u4e32\uff0c\u7531\u5c0f\u5beb\u82f1\u6587\u5b57\u6bcd\u7d44\u6210 – \u4f7f\u7528\u8005\u540d\u7a31\u3002\u9019\u500b\u5b57\u4e32\u5305\u542b\u4e86\u6700\u591a100\u500b\u5b57\u6bcd\u3002<\/p>\n\n\n\n
<\/div>\n\n\n\n
\u8f38\u51fa<\/strong><\/p>\n\n\n\nIf it is a female by our hero’s method, print “CHAT WITH HER!” (without the quotes), otherwise, print “IGNORE HIM!” (without the quotes).<\/p>\n\n\n\n
\u8981\u662f\u9019\u500b\u6a21\u5f0f\u5f97\u5230\u5973\u751f\u7684\u7d50\u679c\uff0c\u5370\u51fa”CHAT WITH HER!” (\u4e0d\u7528\u5f15\u865f)\u3002\u82e5\u975e\uff0c\u5247\u5370\u51fa “IGNORE HIM!” (\u4e0d\u7528\u5f15\u865f)<\/p>\n\n\n\n
<\/div>\n\n\n\n
\u7bc4\u4f8b<\/strong><\/p>\n\n\n\n\u8f38\u5165<\/td> | wjmzbmr<\/td><\/tr> |
\u8f38\u51fa<\/td> | CHAT WITH HER!<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<\/div>\n\n\n\n \u8f38\u5165<\/td> | xiaodao<\/td><\/tr> | \u8f38\u51fa<\/td> | IGNORE HIM!<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<\/div>\n\n\n\n \u8f38\u5165<\/td> | sevenkplus<\/td><\/tr> | \u8f38\u51fa<\/td> | CHAT WITH HER!<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<\/div>\n\n\n\n \u7b46\u8a18<\/strong><\/p>\n\n\n\nFor the first example. There are 6 distinct characters in “wjmzbmr”. These characters are: “w”, “j”, “m”, “z”, “b”, “r”. So wjmzbmr is a female and you should print “CHAT WITH HER!”.<\/p>\n\n\n\n \u5728\u7b2c\u4e00\u500b\u7bc4\u4f8b\u4e2d\uff0c”wjmzbmr” \u6709\u516d\u500b\u552f\u4e00\u7684\u5b57\u5143\uff0c\u5b83\u5011\u5206\u5225\u662f”w”, “j”, “m”, “z”, “b”, “r”\u3002\u6240\u4ee5 wjmzbmr \u662f\u4e00\u500b\u5973\u751f\uff0c\u800c\u4f60\u61c9\u8a72\u5370\u51fa “CHAT WITH HER!” (\u8ddf\u5979\u804a\u5929)<\/p>\n\n\n\n <\/div>\n\n\n\n
\n\n\n\n <\/span>\u89e3\u984c\u601d\u8def<\/span><\/h2>\n\n\n\n\u5728\u7b2c\u4e00\u500b\u89e3\u7b54\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 HashSet\u4f86\u5132\u5b58\u90a3\u4e9b\u552f\u4e00\u7684\u5b57\u6bcd\uff0c\u5c31\u53ef\u4ee5\u7c21\u55ae\u7684\u8a08\u7b97\u5b83\u5011\u7684\u6578\u91cf\u4e86\u3002<\/p>\n\n\n\n <\/div>\n\n\n\n <\/span>C#\u89e3\u6c7a\u65b9\u6848<\/strong><\/span><\/h3>\n\n\n\n\u65b9\u68481<\/strong><\/p>\n\n\n\nstring username = Console.ReadLine();\nHashSet<char> hSet = new HashSet<char>();\n\nchar[] charArr = username.ToCharArray();\n\nforeach (char c in charArr)\n{\n hSet.Add(c);\n}\n\nstring res = hSet.Count%2==0? "CHAT WITH HER!" : "IGNORE HIM!";\n\nConsole.WriteLine(res);<\/code><\/pre><\/div>\n\n\n\n<\/div>\n\n\n\n \u65b9\u68482<\/strong> – LINQ Distinct<\/p>\n\n\n\nstring username = Console.ReadLine();\n\nint cnt = username.Distinct().Count();\n\nstring res = cnt%2==0? "CHAT WITH HER!" : "IGNORE HIM!";\n\nConsole.WriteLine(res);<\/code><\/pre><\/div>\n\n\n\n\u800c\u7576\u4f60\u4f7f\u7528LINQ \u7684 Distinct <\/em><\/strong>\u4e00\u5207\u8b8a\u5f97\u66f4\u7c21\u55ae\u4e86!<\/p>\n\n\n\n<\/div>\n\n\n\n <\/span>Java\u89e3\u6c7a\u65b9\u6848<\/strong><\/span><\/h3>\n\n\n\n\u65b9\u68481<\/strong><\/p>\n\n\n\nimport java.util.HashSet;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String username = scanner.nextLine();\n HashSet<Character> hSet = new HashSet<>();\n\n char[] charArr = username.toCharArray();\n\n for (char c : charArr) {\n hSet.add(c);\n }\n\n String res = hSet.size() % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!";\n System.out.println(res);\n }\n}<\/code><\/pre><\/div>\n\n\n\n<\/div>\n\n\n\n \u65b9\u68482<\/strong> – streaming<\/p>\n\n\n\nimport java.util.Scanner;\nimport java.util.stream.Collectors;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String username = scanner.nextLine();\n long cnt = username.chars()\n .mapToObj(c -> (char) c)\n .distinct()\n .count();\n\n String res = cnt % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!";\n System.out.println(res);\n }\n}<\/code><\/pre><\/div>\n\n\n\n\u8207C#\u7684 LINQ \u985e\u4f3c\uff0cJava\u4e5f\u53ef\u4ee5\u4f7f\u7528streaming\u4f86\u8f15\u9b06\u53d6\u5f97\u552f\u4e00\u4e26\u8a08\u7b97\u6578\u91cf<\/p>\n\n\n\n <\/div>\n\n\n\n
|
|
|