Pagini recente » Cod sursa (job #2014427) | Statistici Snoopadelik (alexxx01) | Cod sursa (job #2068157) | Monitorul de evaluare | Cod sursa (job #2456746)
// (incarcarile precedente)
// timp de executie local PE TESTUL MAXIMAL: 0.404s
// timp de executie infoarena: >0.550s
// MA OFER SA CUMPAR PROCESOR PENTRU INFOARENA
#pragma GCC optimize("O3")
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream in("trapez.in");
ofstream out("trapez.out");
struct punct
{
long double x, y;
};
istream & operator>> (istream & is, punct & p)
{
is >> p.x >> p.y;
return is;
}
long double panta(punct a, punct b)
{
return (a.x == b.x) ? 1e20 : ((a.y - b.y) / (a.x - b.x));
}
vector<long double> pante;
int n;
punct v[1000];
unsigned long long ans;
int main()
{
in >> n;
for(int i = 0; i < n; i++)
in >> v[i];
for(int i = 0; i < n; i++)
for(int j = i+1; j < n; j++)
pante.push_back(panta(v[i], v[j]));
sort(pante.begin(), pante.end());
int cnt = 1;
for(int i = 1; i < pante.size(); i++)
{
if(pante[i] == pante[i-1])
cnt++;
else
{
ans += cnt * (cnt - 1) / 2;
cnt = 1;
}
}
ans += cnt * (cnt - 1) / 2;
out << ans;
return 0;
}