Pagini recente » Cod sursa (job #3283847) | Cod sursa (job #1402914) | Profil DenisONIc | Rating ghoerghe (bistritianul) | Cod sursa (job #3286048)
#include <fstream>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
ifstream fcin("triang.in");
ofstream fout("triang.out");
int n;
const double limit=0.0001, cos60=0.5, sin60=sqrt(3)/2.0;
struct pct
{
double x;
double y;
};
pct v[2000];
struct cmp
{
bool operator()(const pct &a, const pct &b) const
{
if(abs(a.x-b.x>limit)) return a.x<b.x;
if(abs(a.y-b.y>limit)) return a.y<b.y;
return false;
}
};
set <pct, cmp> s;
inline pct get_point(int i, int j)
{
pct p1=v[i], p2=v[j], rez;
rez.y=(p2.x-p1.x)*sin60+(p2.y-p1.y)*cos60+p1.y;
rez.x=(p2.x-p1.x)*cos60-(p2.y-p1.y)*sin60+p1.x;
return rez;
}
int main()
{
fcin>>n;
for(int i=1; i<=n; i++)
fcin>>v[i].x>>v[i].y;
int rez=0;
for(int i=1; i<n; i++)
{
for(int j=i+1; j<=n; j++)
{
if(s.count(get_point(i,j)))
rez++;
}
s.insert(v[i]);
}
fout<<rez;
return 0;
}