• + 0 comments
    int getTotalX(vector<int> a, vector<int> b) {
        // assume vectors are sorted and a_n <= b_1    
        int betweenCount = 0;
        
        for (int q = a.back(); q <= b.front(); q += a.back()) {
            bool isMultiple = std::all_of(a.begin(), a.end(),
                [q] (int el) { return q % el == 0; }); 
            bool isFactor = std::all_of(b.begin(), b.end(),
                [q] (int el) { return el % q == 0; });
            if (isMultiple && isFactor)
                betweenCount++;
        }
        
        return betweenCount;
    }