Pagini recente » Cod sursa (job #1402914) | Profil DenisONIc | Rating ghoerghe (bistritianul) | Cod sursa (job #3286048) | Cod sursa (job #3285844)
#include <fstream>
#include <unordered_map>
#include <cmath>
using namespace std;
ifstream fcin("triang.in");
ofstream fout("triang.out");
int n;
const double cos60 = 0.5;
const double sin60 = sqrt(3) / 2;
struct pct
{
double x;
double y;
bool operator==(const pct &a) const
{
return x==a.x && y==a.y;
}
};
pct v[2001];
struct HASH
{
size_t operator()(const pct &a) const
{
return hash <long long>() ((hash<double>()(a.x)) ^ ((hash<double>()(a.y))<<32));
}
};
unordered_map<pct,int, HASH> mp;
pct get_point( int i, int j )
{
pct p1 = v[i], p2 = v[j], ret;
ret.x = cos60 * (p1.x - p2.x) - sin60 * (p1.y - p2.y) + p2.x;
ret.y = sin60 * (p1.x - p2.x) + cos60 * (p1.y - p2.y) + p2.y;
return ret;
}
int main()
{
fcin>>n;
for(int i=1; i<=n; i++)
{
fcin>>v[i].x>>v[i].y;
mp[v[i]]=1;
}
int rez=0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<i; j++)
{
pct g=get_point(i,j);
fout<<g.x<<" "<<g.y<<"\n";
if(mp.count(g))
rez++;
}
}
fout<<rez;
return 0;
}