Pagini recente » Cod sursa (job #1183836) | Cod sursa (job #1434228) | Cod sursa (job #1752808) | Cod sursa (job #1119493) | Cod sursa (job #965553)
Cod sursa(job #965553)
#include <cstdio>
#include <algorithm>
#include <utility>
#include <tr1/unordered_set>
#include <cmath>
#define x first
#define y second
using namespace std;
const double EPS = 1e-6;
const double PI = 3.1415926535897932384626433832795;
typedef pair<double,double> point;
point P[1502];
struct Hasher{
int operator()(const point &A)const
{
const double fst = A.x * PI + A.y;
return int(fst);
}
};
struct Hash_eq{
bool operator()(const point &A,const point &B)const
{
return abs(A.x-B.x) <= EPS && abs(A.y-B.y) <= EPS;
}
};
tr1::unordered_set<point,Hasher,Hash_eq> T;
int n;
double csin,sn;
point rotate(const point &P,double angle)
{
angle = PI * angle / 180.0;
double cs = cos(angle),sn = sin(angle);
point ret;
ret.x = P.x * cs - P.y * sn;
ret.y = P.x * sn + P.y * cs;
return ret;
}
int main()
{
freopen("triang.in", "r", stdin);
freopen("triang.out", "w", stdout);
scanf("%d",&n);
for(int i = 1 ; i <= n ; ++ i)
scanf("%lf%lf",&P[i].x,&P[i].y);
sort(P+1,P+n+1);
int show = 0;
point sought,norm;
for(int i = 1 ; i <= n ; ++ i){
for(int j = 1 ; j < i ; ++ j){
norm.x = P[j].x - P[i].x;
norm.y = P[j].y - P[i].y;
sought = rotate(norm,60);
sought.x += P[i].x;
sought.y += P[i].y;
if(T.count(sought))
++show;
}
T.insert(P[i]);
}
printf("%d\n",show);
return 0;
}