Pagini recente » Cod sursa (job #2487654) | Cod sursa (job #1882196) | Cod sursa (job #1204447) | Cod sursa (job #1991423) | Cod sursa (job #963425)
Cod sursa(job #963425)
/// !TRAPEZ - it's chest day :)
#include <fstream>
#include <vector>
#include <algorithm>
#define x first
#define y second
using namespace std;
const int DN = 1005;
pair<int, int> points[DN];
double slope[DN * DN];
int n, slopes;
int Answer;
int main()
{
ifstream cin("trapez.in");
ofstream cout("trapez.out");
cin >> n;
for(int i = 1 ; i <= n ;++ i)
cin >> points[i].x >> points[i].y;
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j)
slope[++slopes] = (double)(points[i].first - points[j].first) / (points[i].second - points[j].second);
stable_sort(slope + 1, slope + slopes + 1);
for(int i = 1 ; i <= slopes; ++ i)
{
int nr = 1;
while( i + 1 <= slopes && slope[i] == slope[i+1] )
{
++ nr;
++ i;
}
Answer += (nr*(nr-1))/2;
}
cout << Answer << "\n";
return 0;
}