➽ Problem:-

https://www.hackerrank.com/challenges/between-two-sets/problem

➽ Solution:-

#include<iostream>

using namespace std;

int main()

{

    int a, b;

    cin >> a >> b;

    int x[100], y[100];

    for(int i=0; i<a; i++)

    {

        cin >> x[i];

    }

    for(int i=0; i<b; i++)

    {

        cin >> y[i];

    }

    int ans = 0;

    for(int j=1; j<=100; j++)

    {

        int temp = 1;

       

        for(int i=0; i<a; i++)

            if(j % x[i] != 0)

                temp = 0;

       

        for(int i=0; i<b; i++)

            if(y[i] % j != 0)

                temp = 0;

               

        if(temp==1)

            ans++;

    }

    cout << ans;

    return 0;

}