Pagini recente » Cod sursa (job #2118101) | Cod sursa (job #3149345) | Cod sursa (job #781988) | Cod sursa (job #156304) | Cod sursa (job #3279323)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
int n,i,j;
long long sol;
struct punct{
int x,y;
}v[1005];
map <pair<int,int>, int> mp;
punct simp(punct a){
int aux = __gcd(abs(a.x), abs(a.y));
return {a.x/aux, a.y/aux};
}
pair<int,int>getD(punct a, punct b){
punct aux = {b.x-a.x, b.y-a.y};
aux = simp(aux);
return make_pair(aux.x, aux.y);
}
int main(){
fin>>n;
for(i=1;i<=n;i++)
fin>>v[i].x>>v[i].y;
for(i=1;i<=n;i++){
for(j=i+1;j<=n;j++){
mp[getD(v[i], v[j])]++;
}
}
for(auto &[x,y]:mp){
sol = sol+y*(y-1)/2;
}
fout<<sol;
return 0;
}