Pagini recente » Cod sursa (job #837925) | Cod sursa (job #2532679) | Cod sursa (job #405732) | Cod sursa (job #1184484) | Cod sursa (job #1981448)
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const double eps = 1.e-14;
const double inf = 2.e9;
struct POINT{
int x;
int y;
};
double panta(POINT A, POINT B){
if(A.x == B.x)return inf;
return (double)(1.0*(B.y - A.y)/(B.x-A.x));
}
int main()
{
ifstream in("trapez.in");
ofstream out("trapez.out");
int n;
in >> n;
vector<POINT> v;
vector<double> pv;
for(int i = 1; i <= n; i++){
POINT p;
in >> p.x >> p.y;
v.push_back(p);
}
for(int i = 0; i < v.size(); i++){
for(int j = i+1; j < v.size(); j++){
pv.push_back(panta(v[i],v[j]));
}
}
sort(pv.begin(), pv.end());
int trapeze = 0;
int nop = 0;
for(int i = 0; i < pv.size()-1; i++){
//cout << pv[i] << endl;
if(fabs(pv[i+1] - pv[i])<eps){
nop++;
}
else{
if(nop!=0)
trapeze = trapeze + nop*(nop+1)/2;
nop = 0;
}
}
out << trapeze;
return 0;
}