Pagini recente » Cod sursa (job #621688) | Cod sursa (job #1039903) | Cod sursa (job #1317701) | Cod sursa (job #2659468) | Cod sursa (job #3279326)
#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));
if(a.y < 0)
a.y = -a.y, a.x = -a.x;
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;
}