Pagini recente » Cod sursa (job #178029) | Cod sursa (job #2836072) | Cod sursa (job #2715976) | Cod sursa (job #1308632) | Cod sursa (job #587866)
Cod sursa(job #587866)
#include<algorithm>
using namespace std;
float abbs(double A) {
if (A<0)
return -A ;
return A ;
}
struct punct{
double x;
double y;
};
punct v[1001];
double p[1000009];
int cnt,cont=1;
int rez,n;
int main(){
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
scanf("%d",&n) ;
for(int i=1;i<=n;++i) {
scanf("%lf%lf",&v[i].x,&v[i].y);
}
for(int i=1;i<n;++i) {
for(int j=i+1;j<=n;++j) {
if (v[i].x!=v[j].x) {
p[++cnt]=(double)(v[i].y-v[j].y)/(v[i].x-v[j].x);
p[cnt]=abbs(p[cnt]) ;
}
else p[++cnt]=-1 ;
}
}
sort(p+1,p+cnt+1) ;
for(int i=2;i<=cnt;++i) {
if(p[i]==p[i-1])
cont++;
else {
rez+=cont*(cont-1)/2 ;
cont=1;
}
}
printf("%d",rez) ;
return 0 ;
}