Pagini recente » Cod sursa (job #689106) | Cod sursa (job #3294188) | Cod sursa (job #1957410) | Cod sursa (job #1964270) | Cod sursa (job #576252)
Cod sursa(job #576252)
#include<algorithm>
using namespace std;
float abbs(float A) {
if (A<0)
return -A ;
return A ;
}
struct punct{
float x;
float y;
};
punct v[1001];
float 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("%d%d",&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]=(float)((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 ;
}