You are viewing a single comment's thread. Return to all comments →
int nonDivisibleSubset(int k, vector<int> s) { vector<int> r(k); for (size_t i = 0; i < s.size(); i++) { r[s[i] % k]++; } r[k/2] = (k % 2 == 0) ? 1 : r[k/2]; int c = (r[0] > 0) ? 1 : 0; for (size_t i = 1; i < k/2 + 1; i++) { c += (r[i] >= r[k-i]) ? r[i] : r[k-i]; } return c; }
Seems like cookies are disabled on this browser, please enable them to open this website
Non-Divisible Subset
You are viewing a single comment's thread. Return to all comments →