Pagini recente » Cod sursa (job #3165064) | Cod sursa (job #1396714) | Cod sursa (job #987387) | Cod sursa (job #2725852) | Cod sursa (job #523318)
Cod sursa(job #523318)
#include <fstream>
#include <iostream>
#include <cmath>
#define LL long long
#define Nmax 1002
#define INF 994325093
using namespace std;
int n;
double panta[Nmax * Nmax];
LL dimp = 0;
struct punct
{
LL x, y;
};
punct a[Nmax];
void pantaa(LL x1, LL y1, LL x2, LL y2)
{
dimp++;
double xx = x1 - x2, yy = y1 - y2;
if(xx == 0)
panta[dimp] = INF;
else
panta[dimp] = yy / (double) xx;
}
int main()
{
ifstream f("trapez.in");
ofstream g("trapez.out");
f >> n;
for(int i = 1; i <= n; ++i)
{
f >> a[i].x >> a[i].y;
for(int j = 1; j < i; ++j)
pantaa(a[i].x, a[i].y, a[j].x, a[j].y);
}
sort(panta + 1, panta + dimp + 1);
/*for(int i = 1; i <= dimp; ++i)
cout << panta[i] << '\n';*/
LL i, k = 1, sol = 0;
for(i = 2; i <= dimp; ++i)
if(fabs(panta[i] - panta[i - 1]) <= 0.000001)
++k;
else
{
if(k > 1) sol += k * (k - 1) / 2;
k = 1;
}
if(k > 1)
sol += k * (k - 1) / 2;
g << sol;
f.close();
g.close();
return 0;
}