-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathABCDEF.cpp
More file actions
42 lines (34 loc) · 866 Bytes
/
Copy pathABCDEF.cpp
File metadata and controls
42 lines (34 loc) · 866 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int N, S[101];
vector <int> ABC, DEF;
int main()
{
ios::sync_with_stdio(false);
cin>>N;
for (int i = 1; i <= N; i++)
cin>>S[i];
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
for (int k = 1; k <= N; k++)
{
int A = S[i], B = S[j], C = S[k];
ABC.push_back(A*B + C);
}
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
for (int k = 1; k <= N; k++)
{
int D = S[i], E = S[j], F = S[k];
if (D != 0)
DEF.push_back((F + E)*D);
}
sort(ABC.begin(), ABC.end());
sort(DEF.begin(), DEF.end());
unsigned long long Ans = 0;
for (int i = 0; i < ABC.size(); i++)
if (binary_search(DEF.begin(), DEF.end(), ABC[i]))
Ans += distance(lower_bound(DEF.begin(), DEF.end(), ABC[i]), upper_bound(DEF.begin(), DEF.end(), ABC[i]));
cout<<Ans<<endl;
return 0;
}