Pagini recente » Cod sursa (job #769908) | Cod sursa (job #2650810) | Cod sursa (job #722276) | Cod sursa (job #729226) | Cod sursa (job #704162)
Cod sursa(job #704162)
#include <fstream>
#include <algorithm>
using namespace std;
int n,x[1010],y[1010],lung,sol;
double p[1000100];
inline double panta(int x1,int y1,int x2,int y2)
{
return 1.0*((1.0*(y2-y1))/(1.0*(x2-x1)));
}
int main()
{
ifstream in("trapez.in");
ofstream out("trapez.out");
in>>n;
for(int i=1;i<=n;++i)
{
in>>x[i]>>y[i];
for(int j=i-1;j>=1;--j)
{
if(x[i]==x[j] || y[i]!=y[j])
p[++lung]=panta(x[i],y[i],x[j],y[j]);
else
p[++lung]=2100000000;
}
}
sort(p+1,p+lung+1);
for(int i=1;i<=lung;++i)
{
int sv=i,nr=0;
while(p[i]==p[sv] && i<=lung)
{
++i;
++nr;
}
sol=sol+nr*(nr-1)/2;
}
out<<sol<<'\n';
out.close();
return 0;
}