Pagini recente » Cod sursa (job #1230052) | Cod sursa (job #486510) | Cod sursa (job #1206128) | Cod sursa (job #476626) | Cod sursa (job #1534865)
#include <stdio.h>
#include <algorithm>
using namespace std;
const int INF = 2100000;
struct puncte
{
int x, y;
}v[1001];
double p[1000 * 1000 + 1];
int nr = 0;
double abs(double x)
{
if( x < 0)
return -x;
else
return x;
}
double calcPanta(int x1, int y1, int x2, int y2)
{
if(x1 == x2)
return INF;
else
{
double val = 1.00 * (y2 - y1)/(x2 - x1);
//val = abs(val);
return val;
}
}
int main()
{
FILE *fin, *fout;
fin = fopen("trapez.in", "r");
fout = fopen("trapez.out", "w");
int n;
fscanf(fin, "%d", &n);
for(int i = 1; i <= n; i++)
fscanf(fin, "%d %d", &v[i].x, &v[i].y);
for(int i = 1; i <= n; i++)
{
for(int j = i + 1; j <= n; j++)
p[++nr] = calcPanta(v[i].x, v[i].y, v[j].x, v[j].y);
}
sort(&p[1], &p[nr + 1]);
int cnt = 0;
int i = 2;
while(i <= n)
{
int x = 1;
while(p[i] - p[i - 1] <=0.0000000000000000001)
{
x++;
i++;
}
x--;
cnt += x*(x + 1)/2;
x++;
if ( x == 1 )
i++;
}
fprintf(fout, "%d", cnt);
return 0;
}