-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBetween_Two_Sets.cpp
More file actions
42 lines (40 loc) · 936 Bytes
/
Between_Two_Sets.cpp
File metadata and controls
42 lines (40 loc) · 936 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
/**
* Title : Between_Two_Sets.cpp
* Author : Tridib Samanta
* Created : 30-12-2019
* Link : https://www.hackerrank.com/challenges/between-two-sets/problem
**/
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, m;
scanf("%d %d", &n, &m);
int a[100], b[100];
for (int i=0; i<n; i++)
scanf("%d", &a[i]);
for (int i=0; i<m; i++)
scanf("%d", &b[i]);
int cnt = 0;
for (int k=1; k<=100; k++)
{
int flag = 1;
for (int i=0; i<n; i++)
if (k % a[i] != 0)
flag = 0;
for (int i=0; i<m; i++)
if (b[i] % k != 0)
flag = 0;
if (flag == 1)
cnt ++;
}
printf("%d\n", cnt);
return 0;
}