Pagini recente » Cod sursa (job #641882) | Cod sursa (job #938918) | Cod sursa (job #3206657) | Cod sursa (job #1313233) | Cod sursa (job #1142836)
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1.e-14;
const int INF=2<<27;
struct point{
double x,y;
};
point v[1005];
double sol[250000];
double panta(point a,point b){
if(fabs(a.x-b.x)<eps)
return INF;
return (a.y-b.y)/(a.x-b.x);
}
int main(){
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n,xx,yy,i,soln=0,j,r=0,st;
point temp;
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%d%d",&xx,&yy);
temp.x=xx;
temp.y=yy;
v[i]=temp;
}
for(i=0;i<n-1;++i){
for(j=i+1;j<n;++j){
sol[soln+1]=panta(v[i],v[j]);
soln++;
}
}
sort(sol+1,sol+soln+1);
for(i=1;i<soln;++i){
st=i;
while(fabs(sol[st]-sol[i])<eps){
i++;
}
i--;
if(i!=st){
r=r+((i-st+1)*(i-st)/2);
}
}
printf("%d\n",r);
return 0;
}