Pagini recente » Cod sursa (job #185332) | Cod sursa (job #661025) | Cod sursa (job #2245641) | Cod sursa (job #2118634) | Cod sursa (job #2613086)
#include <iostream>
#include <fstream>
#include <set>
#include <cmath>
using namespace std;
const double eps = 1e-5;
struct punct
{
double x, y;
bool operator < (const punct& that) const {
return (fabs(x - that.x) < eps ? y < that.y - eps : x < that.x - eps);
}
};
int main()
{
ifstream in("patrate3.in");
int n;
in >> n;
set<punct> points;
while(n--)
{
punct point;
in >> point.x >> point.y;
points.insert(point);
}
in.close();
int rasp = 0;
//patrat ABCD
for(auto A = points.begin(); A != points.end(); A++)
for(auto C = next(A); C != points.end(); C++)
{
if(A->x < C->x && A->y < C->y)
{
double midX = (A->x + C->x) / 2.0;
double midY = (A->y + C->y) / 2.0;
punct B, D;
B.x = midX - C->y + midY;
B.y = midY + C->x - midX;
D.x = midX + C->y - midY;
D.y = midY - C->x + midX;
if(points.find(B) != points.end() && points.find(D) != points.end())
rasp++;
}
}
ofstream out("patrate3.out");
out << rasp;
out.close();
return 0;
}