fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n ;
  6. cin>>n;
  7. int k;
  8. cin>>k;
  9. int arr[n];
  10. for(int i = 0; i< n ; i++){
  11. cin>>arr[i];
  12. }
  13. int count = 0;
  14. unordered_map<int,int> mpp;
  15. for(int j = 0; j< n ; j++){
  16. int real = arr[j]%k;
  17. int r =( k-real) % k;
  18. count += mpp[r];
  19.  
  20.  
  21. mpp[arr[j]%k] = mpp[arr[j]%k] + 1;
  22. }
  23. cout << count;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5312KB
stdin
7
2
3 2 3 1 1 3 2
stdout
11