Pagini recente » Cod sursa (job #895049) | Cod sursa (job #716149) | Cod sursa (job #2348533) | Cod sursa (job #2281199) | Cod sursa (job #1077580)
#include <fstream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#define x first
#define y second
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
const int MAX_N = 1005;
int n, ans;
vector < pair <int, int> > Point;
unordered_set <double> Set;
unordered_map <double, int> Hash;
void read() {
f >> n;
for (int i = 1; i <= n; i++) {
int x, y;
f >> x >> y;
Point.push_back (make_pair (x, y));
}
}
void solve() {
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
double slope = (double)(Point[j].y - Point[i].y) / (Point[j].x - Point[i].x);
Hash[slope]++;
Set.insert (slope);
}
for (unordered_set <double> :: iterator it = Set.begin(); it != Set.end(); ++it) {
int frecv = Hash[*it];
ans += frecv * (frecv - 1) / 2;
}
}
int main() {
read();
solve();
g << ans;
return 0;
}