Pagini recente » Cod sursa (job #867591) | Cod sursa (job #1544328) | Cod sursa (job #2820729) | Cod sursa (job #1995856) | Cod sursa (job #2607686)
// By Stefan Radu
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <set>
using namespace std;
ifstream cin("trapez.in");
ofstream cout("trapez.out");
#define sz(x) (int)(x).size()
typedef pair < int, int > pii;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;
struct Point {
int x, y;
};
double slope(const Point &a, const Point &b) {
return static_cast < double >(a.y - b.y) / static_cast<double>(a.x - b.x);
}
int main() {
#ifdef STEF
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n; cin >> n;
vector < Point > points(n);
for (auto &p : points) {
cin >> p.x >> p.y;
}
unordered_map < double, int > cnt;
for (int i = 0; i < n; ++ i) {
for (int j = i + 1; j < n; ++ j) {
cnt[slope(points[i], points[j])] += 1;
}
}
int ans = 0;
for (const auto &x : cnt) {
ans += x.second * (x.second - 1) / 2;
}
cout << ans << '\n';
}