Pagini recente » Cod sursa (job #2333446) | Cod sursa (job #3240913) | Cod sursa (job #3346410) | Cod sursa (job #3330819) | Cod sursa (job #3309077)
#include <iostream>
#include <cmath>
#include <fstream>
#include <set>
using namespace std;
ifstream f("triang.in");
ofstream g("triang.out");
const double EPS=1e-4;
int n,rez;
struct punct {
double x,y;
} p[1510];
struct cmp {
bool operator()(const punct &a,const punct &b) const {
if(abs(a.x-b.x)>EPS) {
return a.x<b.x;
}
if(abs(a.y-b.y)>EPS) {
return a.y<b.y;
}
return 0;
}
};
set<punct,cmp>da;
int main() {
f>>n;
for(int i=1; i<=n; i++) {
f>>p[i].x>>p[i].y;
for(int j=1; j<i; j++) {
double pozx=(p[j].x-p[i].x)*0.5-(p[j].y-p[i].y)*sqrt(3)/2.0+p[i].x;
double pozy=(p[j].x-p[i].x)*sqrt(3)/2.0+(p[j].y-p[i].y)*0.5+p[i].y;
if(da.find({pozx,pozy})!=da.end()) {
rez++;
}
}
da.insert(p[i]);
}
g<<rez;
f.close();
g.close();
return 0;
}