Pagini recente » Cod sursa (job #2107222) | Cod sursa (job #833100) | Cod sursa (job #2784029) | Cod sursa (job #2662533) | Cod sursa (job #2410207)
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <cmath>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
map<pair<int, int>, int>slopes;
multiset<pair<int, int>>points;
int n;
int comb(int x){
return x*(x-1)/2;
}
int cmmdc(int x, int y){
if(y == 0)
return x;
return cmmdc(y, x%y);
}
int main() {
pair<int, int>point;
int rez = 0;
f>>n;
for (int i = 0; i < n; ++i) {
f>>point.first;
f>>point.second;
for (auto it:points) {
int c = cmmdc(it.second - point.second, it.first - point.first);
++slopes[{(it.second - point.second) / c, (it.first - point.first) / c}];
}
points.insert(point);
}
for (auto it:slopes) {
rez+=comb(it.second);
}
g<<rez;
return 0;
}