Pagini recente » Cod sursa (job #3255944) | Monitorul de evaluare | Cod sursa (job #306492) | 10.1 | Cod sursa (job #3286070)
#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.00001, 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 nr=0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<i; j++)
{
if(s.count(get_point(i,j)))
nr++;
}
s.insert(v[i]);
}
fout<<nr;
return 0;
}