Pagini recente » Cod sursa (job #961798) | Cod sursa (job #2132274) | Cod sursa (job #1759810) | Cod sursa (job #1089192) | Cod sursa (job #2634016)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream in ("trapez.in");
ofstream out("trapez.out");
int n, x, y;
const int oo=2000000002;
vector <pair <int, int> > puncte;
vector <long double> mapp;
inline long double getSlope(int & x1, int & y1, int & x2, int & y2)
{
if(x1==x2) return oo;
return ((long double)y2-y1)/((long double)x2-x1);
}
int rez, lenact;
int main()
{
in>>n;
mapp.reserve(n*(n-1)/2);
puncte.reserve(n);
for(int i=1; i<=n; i++)
{
in>>x>>y;
for(auto & val : puncte)
mapp.push_back(getSlope(x, y, val.first, val.second));
puncte.push_back({x, y});
}
sort(mapp.begin(), mapp.end());
lenact++;
for(int i=1; i<mapp.size(); i++)
{
if(mapp[i]==mapp[i-1]) lenact++;
else lenact=1;
rez+=lenact-1;
}
out<<rez;
return 0;
}