Pagini recente » Cod sursa (job #3249259) | Cod sursa (job #187141) | Cod sursa (job #2560239) | Cod sursa (job #2671426) | Cod sursa (job #2096471)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin ("trapez.in");
ofstream fout ("trapez.out");
int n, x, y, k;
int i, j;
const int oo=2000000005;
double numarator, numitor;
double M[1000005];
int contor=1, S;
struct Punct
{
int x, y;
} P[1005];
int main()
{
fin>>n;
for (i=1; i<=n; i++)
fin>>P[i].x>>P[i].y;
for (i=1; i<=n; i++)
for (j=i+1; j<=n; j++)
{
k++;
numarator = P[i].y - P[j].y;
numitor = P[i].x - P[j].x;
if (numitor==0)
M[k]=oo;
else
M[k]=double(numarator/numitor);
}
sort (M+1, M+k+1);
for (i=2; i<=k; i++)
{
if (M[i-1]==M[i])
contor++;
else
{
S=S+(contor-1)*contor/2;
contor=1;
}
}
fout<<S<<"\n";
return 0;
}