fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,x; cin >> n >> x;
  6. vector<int> arr(n);
  7. for(int i = 0; i < n; i++)
  8. cin >> arr[i];
  9.  
  10. unordered_map<int,int> mp;
  11. int cnt = 0;
  12. for(int i = 0; i < n; i++){
  13. int req = (x - (arr[i]%x))%x;
  14. if(mp.find(req) != mp.end())
  15. cnt += mp[req];
  16.  
  17. mp[arr[i] % x]++;
  18. }
  19. cout << cnt;
  20. return 0;
  21. }
Success #stdin #stdout 0s 5312KB
stdin
5 60
31 25 85 29 35
stdout
3