Pagini recente » preoji/clasament/10 | Cod sursa (job #2686988) | Istoria paginii runda/bursele_agora/clasament | Istoria paginii runda/oji2010/clasament | Cod sursa (job #2673391)
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
const double PI = 2.0 * acos(0);
const double eps = 1.0e-14;
const double INF = 2.0e9;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
double panta[600001];
class POINT
{
public:
double x, y;
POINT()
{
x = y = 0;
}
POINT(double x0, double y0)
{
x = x0;
y = y0;
}
POINT(const POINT& other)
{
x = other.x;
y = other.y;
}
void setxy(double x0, double y0)
{
x = x0;
y = y0;
}
double getx()
{
return x;
}
double gety()
{
return y;
}
double dist(const POINT& other)
{
return sqrt((x - other.x) * (x - other.x) + (y - other.y) * (y - other.y));
}
double calcularepanta(const POINT& other)
{
if (fabs(other.x - x) < eps)
return INF;
return (other.y - y) / (other.x - x);
}
};
int main()
{
int n, i, j, nr = 0, c = 1, x, y, k = 0;
fin >> n;
POINT p[1001];
for (i = 0; i < n; i++)
{
fin >> x >> y;
p[i].setxy(x, y);
}
for (i = 0; i < n - 1; i++)
for (j = i + 1; j < n; j++)
if (p[i].x != p[j].x * (-1))
panta[k++] = p[i].calcularepanta(p[j]);
sort(panta, panta + k);
panta[-1] = -10000000;
for (i = 0; i <= k; i++)
if (panta[i] == panta[i - 1])
c++;
else
{
nr += (c * (c - 1)) / 2;
c = 1;
}
nr += (c * (c - 1)) / 2;
fout << nr;
return 0;
}