Pagini recente » Cod sursa (job #2900560) | Cod sursa (job #3128372) | Cod sursa (job #2227688) | Cod sursa (job #2063091) | Cod sursa (job #1981384)
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const double eps=1.e-14;
const double INF=2000000005;
struct POINT{
double x,y;
}z;
vector <POINT> v;
vector <double> pant;
double panta(POINT A, POINT B){
if(fabs(A.x-B.x)<eps)
return INF;
return (1.0*B.y-A.y)/(B.x-A.x);
}
int main(){
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n;
scanf("%d", &n);
for(int i=1;i<=n;i++){
scanf("%lf%lf", &z.x, &z.y);
v.push_back(z);
}
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
pant.push_back(panta(v[i], v[j]));
sort(pant.begin(), pant.end());
long long sol=0;
for(int i=0;i<(int)pant.size();i++){
int ind=i,nr=0;
while(i<(int)pant.size() && fabs(pant[i]-pant[ind])<eps){
i++;
nr++;
}
i--;
sol+=1LL*nr*(nr-1)/2;
}
printf("%lld", sol);
return 0;
}