Pagini recente » Cod sursa (job #1516006) | Cod sursa (job #812621) | Cod sursa (job #1384132) | Cod sursa (job #520646) | Cod sursa (job #1981597)
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
struct point
{
int x,y;
};
point temp;
vector<point>v;
vector<double>p;
const double eps=1.e-14;
const double INF=2.e9;
vector<int>::iterator it;
bool vertical(point A, point B)
{
return A.x==B.x;
}
double panta(point A, point B)
{
if(vertical(A,B)) 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 j,n,i,x2,x1;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d",&x2,&x1);
temp.x=x2;
temp.y=x1;
v.push_back(temp);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<=n-1;j++)
p.push_back(panta(v[i],v[j]));
sort(p.begin(),p.end());
int k,l,lmax;
lmax=0;
l=0;
k=p.size();
for(i=0;i<k;i++)
{
if(fabs(p[i]-p[i+1])<eps) l++;
else
{
if(l!=0) lmax=lmax+l*(l+1)/2;
l=0;
}
}
printf("%d",lmax);
return 0;
}