Pagini recente » Cod sursa (job #409504) | Cod sursa (job #1545342) | Cod sursa (job #2035439) | Cod sursa (job #1235663) | Cod sursa (job #411178)
Cod sursa(job #411178)
# include <fstream>
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# define PI 3.14159265
# define EPS 0.0001
using namespace std;
struct pct {
double x, y;
friend bool operator < (const pct &a, const pct &b)
{
if(a.x+EPS<b.x || (a.x-b.x>-EPS && a.x-b.x<EPS && a.y+EPS<b.y))
return 1;
return 0;
}
};
vector<pct>v;
int n, sol;
void read ()
{
ifstream fin ("patrate3.in");
pct p;
fin>>n;
for (int i=1;i<=n;i++)
{
fin>>p.x>>p.y;
v.push_back(p);
}
}
pct punct (pct a, pct b)
{
pct p1;
p1.x=cos(PI/2)*(b.x-a.x)-sin(PI/2)*(b.y-a.y)+a.x;
p1.y=sin(PI/2)*(b.x-a.x)+cos(PI/2)*(b.y-a.y)+a.y;
return p1;
}
void solve ()
{
pct p1, p2, p;
for (int i=0;i<n;i++)
for (int j=i+1;j<n;j++)
{
p.x=(v[i].x+v[j].x)/2;
p.y=(v[i].y+v[j].y)/2;
p1=punct(p, v[i]);
p2=punct(p, v[j]);
if (binary_search(v.begin(), v.end(), p1))
if (binary_search(v.begin(), v.end(), p2))
sol++;
}
}
int main ()
{
read();
sort(v.begin(), v.end());
solve ();
ofstream fout ("patrate3.out");
fout<<sol/2;
return 0;
}