Pagini recente » Cod sursa (job #2808439) | Cod sursa (job #1223735) | Statistici Gheorghe Munteanu Murgoci (murgoci2) | Cod sursa (job #252969) | Cod sursa (job #1024980)
#include<iostream>
#include<fstream>
#include<functional>
#include<math.h>
#include<set>
#define PI 3.141592653
#define ax imt->first
#define ay imt->second
#define bx jmt->first
#define by jmt->second
using namespace std;
int n, k;
float x, y;
ifstream f("triang.in");
ofstream g("triang.out");
set< pair<float, float>> m;
set< pair<float, float>>::iterator imt, jmt;
pair<float, float> p;
const float eps = 1e-3;
const float si = sin(PI / 3.0);
const float co = cos(PI / 3.0);
int main()
{
f>>n;
for(int i=0; i<n; ++i) f>>x>>y, m.insert(make_pair(x, y));
for(imt=m.begin(); imt!=m.end(); ++imt){
jmt=imt;++jmt;
for(; jmt!=m.end(); ++jmt){
p=make_pair(ax + co*(bx - ax) - si*(by-ay),ay + si*(bx - ax) + co*(by - ay));
// cout<<p.first<<' '<<p.second<<'\n';
if(m.find(p)!=m.end()) ++k;
//else cout<<"nu \n";
p=make_pair(bx + co*(ax - bx) - si*(ay-by),ay + si*(ax - bx) + co*(ay - by));
// cout<<p.first<<' '<<p.second<<'\n';
if(m.find(p)!=m.end())++k;
// else cout<<"nu \n";
}
}
// for(imt=m.begin(); imt!=m.end(); ++imt)
// cout<<ax<<' '<<ay<<'\n';
g<<k;
return 0;
}