Pagini recente » Profil Luncasu_Victor | Cod sursa (job #1481675) | Cod sursa (job #3313131) | Cod sursa (job #2433905) | Cod sursa (job #3309078)
#include <iostream>
#include <cmath>
#include <set>
#include <fstream>
using namespace std;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
const double EPS=1e-5;
int n,cate;
struct punct {
double x,y;
} P[1001];
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;
da.insert(P[i]);
}
for(int i=1; i<=n; i++) {
punct mij,cs,cd;
for(int j=i+1; j<=n; j++) {
mij.x=(P[i].x+P[j].x)/2;
mij.y=(P[i].y+P[j].y)/2;
cd.x=mij.y-P[j].y+mij.x;
cd.y=P[j].x-mij.x+mij.y;
cs.x=P[j].y-mij.y+mij.x;
cs.y=mij.x-P[j].x+mij.y;
if(da.find(cd)!=da.end()&&da.find(cs)!=da.end()) {
cate++;
}
}
}
g<<cate/2;
f.close();
g.close();
return 0;
}