fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n, a[4444];
  5. unordered_map <double, int> cnt;
  6.  
  7. int main()
  8. {
  9. cin >> n;
  10. for (int i = 0; i < n; i++)
  11. cin >> a[i];
  12. sort(a, a + n);
  13.  
  14. long long ans = 0;
  15. for (int i = 0; i < n; i++)
  16. {
  17. for (int j = i + 1; j < n; j++)
  18. {
  19. double d = 1. * a[i] / a[j];
  20. if (cnt.count(d))
  21. ans += cnt[d];
  22. }
  23. for (int j = 0; j < i; j++)
  24. cnt[1. * a[j] / a[i]]++;
  25. }
  26.  
  27. cout << ans << endl;
  28. }
Success #stdin #stdout 0s 3484KB
stdin
7
1 1 1 1 2 10 20
stdout
5