@@ -0,0 +1,1270 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0Apublic class Solution %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        int n = in.nextInt();%0A        int m = in.nextInt();%0A        int%5B%5D a = new int%5Bn%5D;%0A        for(int a_i=0; a_i %3C n; a_i++)%7B%0A            a%5Ba_i%5D = in.nextInt();%0A        %7D%0A        int%5B%5D b = new int%5Bm%5D;%0A        for(int b_i=0; b_i %3C m; b_i++)%7B%0A            b%5Bb_i%5D = in.nextInt();%0A        %7D%0A        Arrays.sort(a);%0A        Arrays.sort(b);%0A        ArrayList%3CInteger%3E list = new ArrayList%3CInteger%3E();%0A        for(int i=a%5Ba.length-1%5D;i%3C=b%5B0%5D;i++)%7B%0A           list.add(i);%0A        %7D%0A        int count=0;%0A        for(int i : list)%7B%0A        %09if(checkDivisible(i,b) && checkFactors(i,a))%7B%0A        %09%09count++;%0A        %09%7D%0A        %7D%0A        System.out.println(count);%0A    %7D%0A    %0A    public static boolean checkDivisible(int d,int%5B%5D arr)%7B%0A        for(int i : arr)%7B%0A            if(i%25d!=0)%7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A    %0A    public static boolean checkFactors(int d,int%5B%5D arr)%7B%0A    %09for(int i : arr)%7B%0A            if(d%25i!=0)%7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A%0A

add BetweenTwoSets.java