Pagini recente » Cod sursa (job #3291755) | Rating Serban Paul (xorion) | Cod sursa (job #3291919) | Cod sursa (job #1055060) | Cod sursa (job #1330068)
#include <fstream>
#include <algorithm>
#define EPSILON 0.001
#define INFINIT 999999
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
struct Punct
{
int x, y;
};
int N;
Punct P[1001];
double Pante[1000001];
double Panta( Punct A, Punct B )
{
if( B.x == A.x )
return INFINIT;
return (double)(B.y - A.y) / (B.x - A.x);
}
int main()
{
fin >> N;
for( int i = 1; i <= N; ++i )
fin >> P[i].x >> P[i].y;
int ind = 0;
for(int i = 1; i < N; ++i)
for( int j = i + 1; j <= N; ++j )
Pante[++ind] = Panta( P[i], P[j] );
sort( Pante + 1, Pante + 1 + ind );
fout << '\n';
int S = 0;
int L = 1;
for( int i = 2; i <= ind; ++i )
{
if( Pante[i] - Pante[i - 1] < EPSILON )
L++;
else
{
if( L >= 2 )
S += L * (L - 1) / 2;
L = 1;
}
}
fout << S;
return 0;
}