Pagini recente » Cod sursa (job #2757228) | Cod sursa (job #3191522) | Cod sursa (job #702035) | Cod sursa (job #882796) | Cod sursa (job #803815)
Cod sursa(job #803815)
#include<fstream>
#include<cmath>
#include<algorithm>
using namespace std;
struct pct
{
double x,y;
};
const double t=1e-14;
long long s,l;
double a[1000000];
pct v[1001];
int i,n,m,j;
bool egal(double x,double y)
{
if (isinf(x))
return isinf(y);
else return fabs(x-y)<t;
}
int main()
{
ifstream f("trapez.in");
ofstream g("trapez.out");
f >> n;
for (i=1;i<=n;i++)
f >> v[i].x >> v[i].y;
for (i=1;i<=n;i++)
for (j=i+1;j<=n;j++)
a[++m]=(v[i].y-v[j].y)/(v[i].x-v[j].x);
sort(a+1,a+m+1);
for (i=1;i<=m;i++)
{
l=1;j=i;
while ((++j<=m) && (egal(a[i],a[j])))
l++;
i=j-1;
s+=l*(l-1)/2;
}
g << s;
}