Pagini recente » Cod sursa (job #1964427) | Cod sursa (job #1808685) | Cod sursa (job #1190347) | Cod sursa (job #223077) | Cod sursa (job #1706802)
#include <bits/stdc++.h>
using namespace std;
const double INF = 2.e9;
const double eps = 1.e-14;
struct POINT
{
int x, y;
}v[1005];
double panta (POINT A, POINT B)
{
if(fabs(A.x - B.x) < eps)
return INF;
return 1.0 * (B.y - A.y) / (B.x - A.x) * 1.0;
}
bool paralele (POINT A, POINT B, POINT C, POINT D)
{
return (fabs(panta(A, B) - panta(C, D)) < eps);
}
double p[500000];
bool cmp(double a, double b)
{
return (a - b) <= -eps;
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n; cin >> n;
for(int i = 1; i <= n; ++i){
int x, y; cin >> x >> y;
v[i].x = x; v[i].y = y;
}
int nr = 0;
for(int i = 1; i <= n; ++i){
for(int j = i + 1; j <= n; ++j){
p[++nr] = panta(v[i], v[j]);
}
}
sort(p + 1, p + nr + 1);
int l = 1;
int ans = 0;
for(int i = 1; i < nr; ++i){
if(fabs(p[i] - p[i + 1]) < eps){
l++;
}else{
ans += l * (l - 1) / 2;
l = 1;
}
}
cout << ans;
return 0;
}