-
Notifications
You must be signed in to change notification settings - Fork 9
/
ABCDEF - ABCDEF.cpp
44 lines (44 loc) · 1.03 KB
/
ABCDEF - ABCDEF.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n;
scanf("%d",&n);
vector<ll> arr(n);
for(int i=0; i<n; i++) scanf("%lld",&arr[i]);
unordered_map<ll, ll> mpl,mpr;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
ll x = (arr[i] + arr[j]);
for(int k=0; k<n; k++){
if(arr[k]!=0){
ll tmp = x*arr[k];
mpr[tmp]++;
}
}
}
}
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
ll x = (arr[i] * arr[j]);
for(int k=0; k<n; k++){
ll tmp = x+arr[k];
mpl[tmp]++;
}
}
}
ll ans = 0;
auto it = mpl.begin();
while(it!=mpl.end()){
ll a = it->first;
ll x = it->second;
if(mpr.find(a)!=mpr.end()){
ll y = mpr[a];
ans= ans + x*y;
}
it++;
}
printf("%lld\n",ans);
return 0;
}