-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCD.java
More file actions
36 lines (32 loc) · 1.1 KB
/
CD.java
File metadata and controls
36 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.*;
import java.util.*;
public class Main {
static int n, m, ans;
static Set<Integer> cd;
static StringTokenizer st;
static StringBuilder sb = new StringBuilder();
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws Exception {
while(true){
pre_setting();
if(n == 0 && m == 0) break;
}
bw.append(sb);
bw.close();
}
static void pre_setting() throws Exception{
st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
int ans = 0;
cd = new HashSet();
for(int i = 0; i < n; i++){
cd.add(Integer.parseInt(br.readLine()));
}
for(int i = 0; i < m; i++){
if(cd.contains(Integer.parseInt(br.readLine()))) ans++;
}
if(n != 0 && m != 0) sb.append(ans).append("\n");
}
}