Pagini recente » Cod sursa (job #2460361) | Cod sursa (job #2936962) | Cod sursa (job #2737204) | Cod sursa (job #1654275) | Cod sursa (job #1162200)
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
const int Nmax = 1000;
const double EPS = 1e-9;
#define x first
#define y second
typedef long long ll;
struct Point
{
int x, y;
friend istream& operator >> ( istream &f, Point &P )
{
f >> P.x >> P.y;
return f;
}
};
double slopes[Nmax * Nmax];
Point P[Nmax + 1];
int N;
int main()
{
ifstream f("trapez.in");
ofstream g("trapez.out");
f >> N;
for ( int i = 1; i <= N; ++i )
f >> P[i];
int M = 0;
for ( int i = 1; i < N; ++i )
for ( int j = i + 1; j <= N; ++j )
slopes[ ++M ] = atan2( P[i].x - P[j].x, P[i].y - P[j].y );
sort( slopes + 1, slopes + 1 + M );
double last_s = slopes[1];
ll contor = 1;
ll sol = 0;
for ( int i = 2; i <= M; ++i )
{
if ( abs( slopes[i - 1] - slopes[i] ) < EPS ) contor++;
else
{
sol += contor * ( contor - 1 ) / 2LL;
contor = 1;
}
last_s = slopes[i];
}
sol += contor * ( contor - 1 ) / 2LL;
g << sol << "\n";
return 0;
}