forked from srikanthmalipatel/Spoj-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABCDEF-6726594-src.cpp
More file actions
54 lines (50 loc) · 1.02 KB
/
ABCDEF-6726594-src.cpp
File metadata and controls
54 lines (50 loc) · 1.02 KB
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
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <cmath>
using namespace std;
#define MAX_N 101
int n,x[MAX_N],lo,hi;
long long res=0LL;
vector<int>s1,s2;
int main()
{
scanf("%d",&n);
for (int i=0;i<n;i++)
{
scanf("%d",&x[i]);
}
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
for (int k=0;k<n;k++)
{
s1.push_back(x[i]*x[j]+x[k]);
}
}
}
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
for (int k=0;k<n;k++)
{
if (x[k]==0) continue;
s2.push_back((x[i]+x[j])*x[k]);
}
}
}
sort(s1.begin(),s1.end());
sort(s2.begin(),s2.end());
for (int i=0;i<s1.size();i++)
{
lo=lower_bound(s2.begin(),s2.end(),s1[i])-s2.begin();
hi=upper_bound(s2.begin(),s2.end(),s1[i])-s2.begin();
res+=(hi-lo);
}
printf("%lld\n",res);
return 0;
}