Pagini recente » Cod sursa (job #2886349) | Cod sursa (job #1460605) | Cod sursa (job #503823) | Cod sursa (job #476577) | Cod sursa (job #1077588)
#include <fstream>
#include <vector>
#include <algorithm>
#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;
vector <double> Slopes;
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);
Slopes.push_back (slope);
}
sort (Slopes.begin(), Slopes.end());
int i = 0;
while (i < Slopes.size()) {
int j = i;
while (j < Slopes.size() && Slopes[i] == Slopes[j])
j++;
int frecv = j - i;
ans += frecv * (frecv - 1) / 2;
i = j;
}
}
int main() {
read();
solve();
g << ans;
return 0;
}