やるだけ
class FactoVisors { public: int getNum(vector <int> D, vector <int> M) { set<lli> ns[M.size()]; for (int i = 0; i < (int)M.size(); ++i) { for (lli j = 1; j * j <= M[i]; ++j) { if (M[i] % j == 0) { ns[i].insert(j); ns[i].insert(M[i] / j); } } } set<lli> cand; FOR (i, ns[0]) { bool flg = true; for (int j = 0; j < (int)M.size(); ++j) { flg = flg && ns[j].count(*i); } if (flg) cand.insert(*i); } int ret = 0; FOR (i, cand) { bool flg = true; for (int j = 0; j < (int)D.size(); ++j) { flg = flg && *i % D[j] == 0; } ret += flg; } return ret; } };