Pagini recente » Cod sursa (job #1290087) | Cod sursa (job #474714) | Cod sursa (job #2201629) | Cod sursa (job #261390) | Cod sursa (job #1024974)
#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;
double x, y;
ifstream f("triang.in");
ofstream g("triang.out");
set< pair<double, double>> m;
set< pair<double, double>>::iterator imt, jmt;
pair<double, double> p;
const double eps = 1e-3;
const double si = sin(PI / 3.0);
const double 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-n)/3;
return 0;
}