Pagini recente » Cod sursa (job #3182017) | Cod sursa (job #1947634) | Cod sursa (job #1224590) | Cod sursa (job #3238684) | Cod sursa (job #2296160)
#include<cstdio>
#include<algorithm>
using namespace std;
struct dr
{
int x;
int y;
};
int x[1005], y[1005];
double perechi[1000000];
bool cmp(dr a, dr b)
{
if(a.y == 0 || b.y == 0)
{
if(a.y == 0 && b.y == 0)
return 0;
else
if(a.y == 0)
return 0;
else
return 1;
}
if((double) a.x / a.y > (double)a.x / b.y)
return 1;
else
return 0;
}
int same(dr a, dr b)
{
if(a.y == 0 || b.y == 0)
{
if(a.y == 0 && b.y == 0)
return 1;
else
return 0;
}
if((double) a.x / a.y - (double)b.x / b.y <= 0.00001 && (double) a.x / a.y - (double)b.x / b.y >= 0 - 0.00001)
return 1;
else
return 0;
}
int main()
{
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
int n, i, j, nr = 0, nc;
long long a, b, sum = 0;
scanf("%d", &n);
for(i = 1; i <= n; ++ i)
scanf("%d%d", &x[i], &y[i]);
for(i = 1; i < n; ++ i)
for(j = i + 1; j <= n; ++ j)
{
perechi[++ nr].x = (double)(x[i] - x[j]) / (y[i] - y[j]);
}
sort(perechi + 1, perechi + nr + 1);
for(i = 1; i <= nr; ++ i)
{
nc = 0;
while(perechi[i] == perechi[i + nc + 1] && i + nc < nr)
{
++ nc;
}
sum = sum + (long long) (((long long)nc * (nc + 1))/2);
}
printf("%lld", sum);
return 0;
}