Guest User

Untitled

a guest
Mar 4th, 2018
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. 6
  2. DEVELOPER.@gmail.com
  3. t+es+ter@GMAIL.COM
  4. T@bmail.com
  5. a@gmail.com.ru
  6. D.eveloper@Gmail.Com
  7. a+b@gmail.com.ru
  8.  
  9. 5
  10. 1 a@gmail.com.ru
  11. 1 t+es+ter@GMAIL.COM
  12. 2 DEVELOPER.@gmail.com D.eveloper@Gmail.Com
  13. 1 a+b@gmail.com.ru
  14. 1 T@bmail.com
  15.  
  16. import java.util.HashMap;
  17. import java.util.Map;
  18. import java.util.Scanner;
  19.  
  20. public class Mails {
  21.  
  22. public static void main(String[] args) {
  23. Map<String, String> map = new HashMap<>();
  24. Scanner sc = new Scanner(System.in);
  25. int n = Integer.parseInt(sc.nextLine());
  26. for (int i = 0; i < n; i++) {
  27. String str1 = sc.nextLine();
  28. String str2 = str1.toLowerCase();
  29. String[] arr1 = str2.split("@");
  30. if (arr1[1].equals("gmail.com")) {
  31. str2 = arr1[0].replace(".", "") + "@gmail.com";
  32. if (str2.contains("+")) {
  33. String[] arr2 = str2.split("\+");
  34. str2 = arr2[0] + "@gmail.com";
  35. }
  36. }
  37. if (map.containsKey(str2)) {
  38. String value = map.get(str2);
  39. map.put(str2, value + " " + str1);
  40. }
  41. else {
  42. map.put(str2, str1);
  43. }
  44. }
  45. System.out.println(map.size());
  46. for (String value: map.values()) {
  47. int count = value.split(" ").length;
  48. System.out.println(count + " " + value);
  49. }
  50. }
  51. }
Add Comment
Please, Sign In to add comment