• + 0 comments

    int getTotalX(vector a, vector b) { vector lcm = {}; vector hcf = {};

    int start_point = *max_element(a.begin(), a.end());
    int end_point = *min_element(b.begin(), b.end());
    for (int i = start_point; i <= end_point; i++)
        {
        bool a_flag = true;
        bool b_flag = true;
        for (int a_temp : a)
            {
            if (i%a_temp != 0)
                {
                a_flag = false;
                break;
                }
            }
        if (a_flag)
            {
            lcm.push_back(i);
            }
        for (int b_temp : b)
            {
            if (b_temp%i != 0)
                {
                b_flag = false;
                break;
                }
            }
        if (b_flag)
            {
            hcf.push_back(i);
            }
        }
    vector<int> res;
    set_intersection(lcm.begin(), lcm.end(), hcf.begin(), hcf.end(), back_inserter(res));
    return res.size();
    

    }