-
Notifications
You must be signed in to change notification settings - Fork 28
/
abcdef.cpp
76 lines (69 loc) · 1.79 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
int n;
long long rj = 0;
cin >> n;
int x;
vector<int> S;
map<long long, long long> intovi;
for (int i = 0; i < n; ++i)
{
cin >> x;
S.push_back(x);
}
// sort(S.begin(), S.end());
for (int i = 0; i < n; ++i)
{
for (int j = i; j < n; ++j)
{
long long iPutaJ = S[i] * S[j];
for (int k = 0; k < n; ++k)
{
long long zbroj = iPutaJ + S[k];
map<long long, long long>::iterator it = intovi.find(zbroj);
if (it == intovi.end())
{
if (S[i] != S[j])
intovi[zbroj] = 2;
else
intovi[zbroj] = 1;
}
else
{
if (S[i] != S[j])
it->second += 2;
else
it->second++;
}
}
}
}
for (int i = 0; i < n; ++i)
{
for (int j = i; j < n; ++j)
{
long long iPlusJ = S[i] + S[j];
for (int k = 0; k < n; ++k)
{
if (S[k] == 0)
continue;
long long umnozak = iPlusJ * S[k];
map<long long, long long>::iterator it = intovi.find(umnozak);
if (it != intovi.end())
{
if (S[i] != S[j])
rj += it->second * 2;
else
rj += it->second;
}
}
}
}
cout << rj << endl;
return 0;
}