-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathABCDEF.cpp
More file actions
57 lines (45 loc) · 1.26 KB
/
ABCDEF.cpp
File metadata and controls
57 lines (45 loc) · 1.26 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
55
56
57
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<iterator>
#include<vector>
using namespace std;
int main()
{
unsigned int sz;
int elem;
vector<int>v, va, vb;
scanf("%u",&sz);
while (sz--){
scanf("%d", &elem);
v.push_back(elem);
}
int size = v.size();
for ( int i =0; i< size; i++)
for ( int j = 0; j<size; j++)
for(int k=0; k<size;k++)
va.push_back((v[i]*v[j])+v[k]);
sort(va.begin(), va.end());
for ( int i =0; i< size; i++)
for ( int j = 0; j<size; j++)
for(int k=0; k<size;k++)
if(v[i]!=0)vb.push_back(v[i]*(v[j]+v[k]));
sort(vb.begin(), vb.end());
int count=0;
for ( int i(0); i<vb.size(); i++){
vector<int>:: iterator ita, itb;
itb = vb.begin();
int tmp(0);
ita = lower_bound(va.begin(),va.end(), *(itb+i) );
if ( *ita == *(itb+i) && *itb<= va.back() )
count++;
while ( *ita == *(ita+1) && *ita == *(itb+i)){
ita++;
tmp++;
}
count += tmp;
}
printf("%d\n",count);
system ("pause");
return 0;
}