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