Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.HashSet;
  5.  
  6.  
  7. public class CD {
  8.     public static void main(String[] args) throws IOException{
  9.         BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  10.  
  11.         while (true) {
  12.             String command = input.readLine();
  13.             if (command.startsWith("0 0")) break;
  14.  
  15.             String[] counts = command.split(" ");
  16.             HashSet<String> jack_cds = new HashSet<String>();
  17.  
  18.             for (int i = 0; i < Integer.parseInt(counts[0]); ++i)
  19.                 jack_cds.add(input.readLine());
  20.  
  21.             int common = 0;
  22.             for (int i = 0; i < Integer.parseInt(counts[1]); ++i)
  23.                 if (jack_cds.contains(input.readLine()))
  24.                     common++;
  25.  
  26.             System.out.println(common);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement