The problem is from codeforces: http://www.codeforces.com/problemset/problem/236/A
This simple problem can be solved easily. I use C# to practice the use of Hashset. Bruteforce O(n) each character and count the identical characters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // acm.steakovercooked.com using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { HashSet<char> aa = new HashSet<char>(); string s = Console.ReadLine(); foreach (char ch in s) { if (!aa.Contains(ch)) { aa.Add(ch); } } Console.Write((aa.Count & 1) == 0 ? "CHAT WITH HER!" : "IGNORE HIM!"); } } } |
// acm.steakovercooked.com using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { HashSet<char> aa = new HashSet<char>(); string s = Console.ReadLine(); foreach (char ch in s) { if (!aa.Contains(ch)) { aa.Add(ch); } } Console.Write((aa.Count & 1) == 0 ? "CHAT WITH HER!" : "IGNORE HIM!"); } } }
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
171 wordsloading...
Last Post: Codeforces: 237A Free Cash
Next Post: Sign Area of Irregular Polygon