-
Notifications
You must be signed in to change notification settings - Fork 0
/
CF215A.java
37 lines (34 loc) · 1013 Bytes
/
CF215A.java
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
37
import java.util.Scanner;
public class CF215A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] arr1= new long[n];
for(int i = 0; i < n; i++) {
arr1[i] = sc.nextInt();
}
int m = sc.nextInt();
long[] arr2= new long[m];
for(int i = 0; i < m; i++) {
arr2[i] = sc.nextInt();
}
long max = 0;
int count = 0;
for(int j = m - 1; j >= 0; j--) {
long bj = arr2[j];
for(int i = 0; i < n; i++) {
long ai = arr1[i];
if(bj%ai == 0) {
long integer = bj/ai;
if(integer > max) {
max = integer;
count = 1;
} else if(integer == max) count++;
else continue;
}
}
}
System.out.println(count);
sc.close();
}
}