You are viewing a single comment's thread. Return to all comments →
int main(){ int n; int k; cin >> n >> k; vector a(n); for(int a_i = 0;a_i < n;a_i++){ cin >> a[a_i]; } int count = 0;
for(int i = 0; i < n; ++i) { for(int j = i+1; j < n; ++j) { if((a[i] + a[j]) % k == 0) { ++count; } } } cout<<count; return 0;
}
No need for i < k check
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 →
int main(){ int n; int k; cin >> n >> k; vector a(n); for(int a_i = 0;a_i < n;a_i++){ cin >> a[a_i]; } int count = 0;
}
No need for i < k check