-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBetweenTwoSets.java
More file actions
67 lines (65 loc) · 1002 Bytes
/
BetweenTwoSets.java
File metadata and controls
67 lines (65 loc) · 1002 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.io.*;
import java.util.Scanner;
class BetweenTwoSets
{
public static void main(String[]args)
{
Scanner venki=new Scanner(System.in);
int n=venki.nextInt();
int m=venki.nextInt();
int C=0,t=0,i,j,k,g=0,c=0,x=0,s,a[]=new int[n],b[]=new int[m];
for(i=0;i<n;i++)
{
a[i]=venki.nextInt();
}
for(j=0;j<m;j++)
{
b[j]=venki.nextInt();
}
for(i=0;i<n;i++)
{
for(j=1;j<=100;j++)
{
x=j%a[i];
if(x==0)
{
System.out.println("A[i] :"+a[i]+" J :"+j);
for(int l=0;l<n;l++)
{
if(a[l]==j)
{
C++;
}
}
for(k=1;k<=100;k++)
{
t=j*k;
for(s=0;s<m;s++)
{
if(t==b[s])
{
/*c++;*/
System.out.println("T :"+t);
for(int l=0;l<n;l++)
{
if(a[l]==j)
{
c++;
}
}
}
}
}
if(c==m)
{
c=0;
g++;
C++;
C=0;
}
}
}
}
System.out.println(g);
}
}