fork(1) download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. map<int, int>mp;
  8.  
  9. map<int, int>mp2;
  10.  
  11. set<int>l;
  12.  
  13. int n, i, j, k, a[102];
  14.  
  15. cin >> n;
  16.  
  17. for(i = 0; i < n; i++){
  18.  
  19. cin >> a[i];
  20. }
  21. for(i = 0; i < n; i++){
  22.  
  23. for(j = 0; j < n; j++){
  24.  
  25. for(k = 0; k < n; k++){
  26.  
  27. l.insert(a[i]*a[j] + a[k]);
  28.  
  29. mp[a[i]*a[j] + a[k]]++;
  30.  
  31. if(a[k] != 0){
  32.  
  33. mp2[a[k]*(a[i] + a[j])]++;
  34. }
  35. }
  36. }
  37. }
  38. int ans = 0;
  39.  
  40. for(auto it = l.begin(); it != l.end(); it++){
  41.  
  42. ans = ans + mp[*it]*mp2[*it];
  43. }
  44. cout << ans;
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 15240KB
stdin
3
5
7
10
stdout
10