Pagini recente » Cod sursa (job #380720) | Cod sursa (job #629459) | Cod sursa (job #1136922) | Cod sursa (job #2602250) | Cod sursa (job #3185182)
#include <fstream>
#include <algorithm>
using namespace std;
const int Nmax = 1000;
struct punct{
long long x, y;
};
punct v[Nmax];
long long pante[Nmax * Nmax];
int main(){
ifstream fin("trapez.in");
ofstream fout("trapez.out");
int n, len, sol, cnt;
fin >> n;
for(int i = 0; i < n; i++){
fin >> v[i].x >> v[i].y;
}
len = 0;
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
pante[len++] = v[i].y - v[j].y;
}
}
sort(pante, pante + len);
sol = 1;
cnt = 1;
for(int i = 1; i < len; i++){
if(pante[i] == pante[i - 1]){
cnt++;
}
else{
if(cnt >= 2){
sol += (cnt - 2) * (cnt - 1);
}
cnt = 0;
}
}
fout << sol;
return 0;
}