Pagini recente » Cod sursa (job #3219157) | Cod sursa (job #2720414) | Cod sursa (job #2774090) | Cod sursa (job #1511625) | Cod sursa (job #2594570)
#include <fstream>
#include <unordered_map>
#include <algorithm>
#include <cmath>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
typedef pair < int, int > PII;
const long double PI = acos(-1);
const int NMAX = 1e3 + 5;
int N;
PII A[NMAX];
unordered_map < long double, int > mp;
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);
++mp[X];
}
return;
}
static inline void Solve ()
{
for(auto it : mp)
if(it.second > 1)
ans += 1LL * (it.second * (it.second - 1LL)) / 2LL;
g << ans << '\n';
return;
}
int main()
{
Read();
Precalculation();
Solve();
return 0;
}