forked from IOSD/Algo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbetween two sets.cpp
63 lines (57 loc) · 1.05 KB
/
between two sets.cpp
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
//https://www.hackerrank.com/challenges/between-two-sets/problem
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n,m,count=0,flag=0;
int arr1[10],arr2[10];
cin>>n;
cin>>m;
for(int i=0;i<n;i++)
{
cin>>arr1[i];
}
for(int i=0;i<m;i++)
{
cin>>arr2[i];
}
int max=arr1[0];
int min=arr2[0];
for(int i=0;i<n;i++)
{
if(arr1[i]>max)
max=arr1[i];
}
for(int i=0;i<m;i++)
{
if(arr2[i]<min)
min=arr2[i];
}
for(int i=max;i<=min;i++)
{
flag=0;
for(int j=0;j<n;j++)
{
if(i%arr1[j]!=0)
{
flag=1;
}
}
for(int j=0;j<m;j++)
{
if(arr2[j]%i!=0)
{
flag=1;
}
}
if(flag==0)
{
count++;
}
}
cout<<count;
return 0;
}