Pagini recente » Cod sursa (job #1845438) | Cod sursa (job #1680706) | Cod sursa (job #1726256) | Cod sursa (job #1059403) | Cod sursa (job #1981598)
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
struct POINT
{
int x,y;
};
vector <POINT> v;
vector <double> pante;
const double eps=1.e-14;
const double INF=2.e9;
bool vertical(POINT A,POINT B)
{
if(A.x==B.x)
return 1;
else
return 0;
}
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 n,a,b,i,j;
POINT temp;
scanf("%d",&n);
for(i=1;i<=n;++i)
{
scanf("%d%d",&a,&b);
temp.x=a;temp.y=b;
v.push_back(temp);
}
for(i=0;i<n-1;++i)
for(j=i+1;j<n;++j)
pante.push_back(panta(v[i],v[j]));
sort(pante.begin(),pante.end());
int k=pante.size(),l=0,s=0;
for(i=0;i<pante.size()-1;i++)
{
if(pante[i+1]==pante[i])
l++;
else
{
if(l!=0)
s=s+l*(l+1)/2;
l=0;
}
}
printf("%d",s);
return 0;
}