Pagini recente » Cod sursa (job #3295496) | Cod sursa (job #3295491) | Cod sursa (job #3295494) | Cod sursa (job #746143) | Cod sursa (job #2757202)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
using namespace std;
ifstream fin ("triang.in");
ofstream fout ("triang.out");
const int MAXN = 1503;
const double precizie = 0.001, pi = 3.1415;
double modul(double x)
{
if(x < 0) return -x;
return x;
}
struct Punct
{
double x, y;
Punct(){};
Punct(double xx, double yy)
{
x = xx;
y = yy;
}
bool operator==(Punct a)
{
return (modul(x - a.x) < precizie && modul(y - a.y) < precizie);
}
bool operator<(const Punct a)
{
if(modul(x - a.x) < precizie)
return y < a.y;
return x < a.x;
}
};
Punct a[MAXN];
int n, res;
bool cauta(Punct x, int lo = 0, int hi = n)
{
int mid = (lo+hi)/2;
if(lo >= hi) return 0;
if(a[mid] == x) return 1;
else if(a[mid] < x) return cauta(x, mid+1, hi);
else return cauta(x, lo, mid);
return 0;
}
int main()
{
fin >> n;
for(int i = 0; i < n; i++)
fin >> a[i].x >> a[i].y;
sort(a, a+n);
for(int i = 0; i < n; i++)
for(int j = i+1; j < n; j++)
{
int x = a[j].x - a[i].x, y = a[j].y - a[i].y;
Punct cautat = Punct(x*cos(pi/3) - y*sin(pi/3), x*sin(pi/3) + y*cos(pi/3));
if(cauta(cautat))res++;
cautat = Punct(x*cos(-pi/3) - y*sin(-pi/3), x*sin(-pi/3) + y*cos(-pi/3));
if(cauta(cautat))res++;
}
fout << res;
return 0;
}