Pagini recente » Cod sursa (job #2496368) | Cod sursa (job #82530) | Cod sursa (job #2807351) | Cod sursa (job #2682793) | Cod sursa (job #849128)
Cod sursa(job #849128)
#include<fstream>
#include<algorithm>
#define inf 32000
using namespace std;
struct pct{int x,y;}v[1002];
int n,i,j,nrp,k=1,rez;
double p[500003];
double panta(pct A,pct B)
{
if(A.x==B.x)return inf;
return (double)(B.y-A.y)/(B.x-A.x);
}
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++)
p[++nrp]=panta(v[i],v[j]);
sort(p+1,p+nrp+1);
for(i=1;i<=nrp;i++)
if(p[i]==p[i-1])k++;
else
{
rez+=k*(k-1)/2;
k=1;
}
g<<rez<<"\n";
f.close();g.close();
}