You are viewing a single comment's thread. Return to all comments →
If anyone is interested here is more modern and clear way of doing the same thing.
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> complenemts(k); int count = 0; int temp; for (int i = 0; i < n; ++i) { cin >> temp; int remainder = (temp % k); int complenemt = (k - remainder) % k; count += complenemts[remainder]; complenemts[complenemt] += 1; } cout << count; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
If anyone is interested here is more modern and clear way of doing the same thing.