Pagini recente » Cod sursa (job #3285288) | Cod sursa (job #446362) | Cod sursa (job #825259) | Cod sursa (job #1361363) | Cod sursa (job #2594573)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
typedef pair < int, int > PII;
const int NMAX = 1e3 + 5;
int N;
PII A[NMAX];
vector < long double > V;
long long ans = 0;
static inline void Read ()
{
f.tie(nullptr);
f >> N;
for(int i = 1; i <= N; ++i)
f >> A[i].first >> A[i].second;
return;
}
static inline void Precalculation ()
{
for(int i = 1; i < N; ++i)
for(int j = i + 1; j <= N; ++j)
{
long double Numa = A[j].second - A[i].second;
long long Numb = A[j].first - A[i].first;
long double X = ((Numb) ? (Numa / Numb) : 1e9);
V.push_back(X);
}
return;
}
static inline void Solve ()
{
sort(V.begin(), V.end());
int Now = 1;
for(int i = 1; i < (int)V.size(); ++i)
{
if(V[i] == V[i - 1])
++Now;
else
{
if(Now > 1)
ans += 1LL * (Now * (Now - 1LL)) / 2LL;
Now = 1;
}
}
if(Now > 1)
ans += 1LL * (Now * (Now - 1LL)) / 2LL;
g << ans << '\n';
return;
}
int main()
{
Read();
Precalculation();
Solve();
return 0;
}