Pagini recente » Cod sursa (job #435841) | Cod sursa (job #1847614) | Cod sursa (job #652798) | Cod sursa (job #2343313) | Cod sursa (job #963424)
Cod sursa(job #963424)
/// !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];
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 j = 1 ; j < i ; ++ j)
slope[++slopes] = (double)(points[j].first - points[i].first) / (points[j].second - points[i].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;
}