Pagini recente » Cod sursa (job #1928320) | Cod sursa (job #3351648) | Cod sursa (job #1014148) | Cod sursa (job #833960) | Cod sursa (job #3351646)
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
struct POINT{
double x,y;
}v[1005];
const double INF=1.e9,eps=1.e-14;
double dist(POINT P1,POINT P2)
{
return sqrt((P2.x-P1.x)*(P2.x-P1.x)+(P2.y-P1.y)*(P2.y-P1.y));
}
bool same_point(POINT P1,POINT P2)
{
if(fabs(P1.x-P2.x)<eps && fabs(P1.y-P2.y)<eps)
return 1;
return 0;
}
POINT median(POINT P1,POINT P2)
{
POINT M;
M.x=(P1.x+P2.x)/2;
M.y=(P1.y+P2.y)/2;
return M;
}
double panta(POINT P1,POINT P2)
{
if(fabs(P2.x-P1.x)<eps)
return INF;
else
return (P2.y-P1.y)/(P2.x-P1.x);
}
double p[1000*999/2+5];
int main()
{
int n,i,k=0,j,cnt=0,l,ll;
fin>>n;
for(i=1;i<=n;i++)
fin>>v[i].x>>v[i].y;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
p[++k]=panta(v[i],v[j]);
sort(p+1,p+k+1);
l=1;
ll=2;
while(l<k && ll<=k)
{
if(fabs(p[l]-p[ll])<eps)
{
cnt=cnt+(ll-l)*(ll-l-1)/2;
l=ll;
ll=l+1;
}
else
ll++;
}
fout<<cnt;
return 0;
}