Pagini recente » Cod sursa (job #366737) | Cod sursa (job #1194303) | antrenament_1 | Cod sursa (job #2372121) | Cod sursa (job #1981400)
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const double eps=1.e-14;
const double INF=2000000000;
struct POINT
{
int x,y;
};
double dist(POINT a,POINT b)
{
return sqrt((a.y-b.y)*(a.x-b.x)+(a.x-b.x)*(a.y-b.y));
}
double panta(POINT a,POINT b)
{
if(a.x==b.x)
return INF;
else
return (1.0*b.y-a.y)/(b.x-a.x);
}
vector<POINT> temp;
vector<double> v;
int nap(double k)
{
int i,a=0;
for(i=1;i<=v.size();i++)
if(v[i]==k)a++;
return a;
}
long long inm(int a,int b)
{
int p=1,i;
for(i=a;i<=b;i++)
p*=i;
return p;
}
int comb(int n,int k)
{
return inm(k,n)/inm(1,k);
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int i,j,n,k=0,prev=-1,s=0;
POINT p;
scanf("%d", &n);
for(i=1;i<=n;i++)
{
scanf("%d%d", &p.x,&p.y);
temp.push_back(p);
}
for(i=1;i<=n-1;i++)
{
for(j=i+1;j<=n;j++)
{
v.push_back(panta(temp[i],temp[j]));
}
}
sort(v.begin(),v.end());
for(i=1;i<v.size();)
{
if(nap(v[i])>1)
s+=comb(nap(v[i]),2);
i+=nap(v[i]);
}
printf("%d\n", s);
return 0;
}