for(int i = 0; i < vec.size(); i++) { for(int j = i + 1; j < vec.size(); j++) { if(!(max(vec[i], vec[j]) % min(vec[i], vec[j]))) sets.erase(max(vec[i], vec[j])); } } }
longsequence(longlong m, set<int> nums, set<longlong> lcms){ long ret = 0; for(int num : nums) { ret += m / num; }
for(long lcm : lcms) { ret -= m / lcm; }
return ret; } public: intnthUglyNumber(int n, int a, int b, int c){ priority_queue<pair<longlong, longlong>> pq; longlong l = 0, r = n * min(a, min(b,c)), m; set<int> nums{a,b,c}; removeMultiplies(nums);