We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int n, k, count = 0;
cin >> n >> k;
int array[n];
for (int i = 0; i < n; i++){
cin >> array[i];
}
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if ((array[i] + array[j]) % k == 0){
count++;
}
}
}
cout << count;
return 0;
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
C++ Code here
include
using namespace std;
int main (){
}