Pagini recente » Cod sursa (job #603572) | Cod sursa (job #761130) | Cod sursa (job #802071) | Cod sursa (job #2714573) | Cod sursa (job #2313548)
#include <fstream>
#include <map>
#include <vector>
#define MULT 1e5
#define EPS 1e-1
using namespace std;
ifstream cin ("patrate3.in");
ofstream cout ("patrate3.out");
class mazi{
public:
long long x, y;
mazi(long long a = 0, long long b = 0){
x = a; y = b;
}
mazi operator - (){
return mazi(-x, -y);
}
void operator += (mazi other){
x += other.x;
y += other.y;
}
mazi operator / (long long other){
return mazi(x / other, y / other);
}
mazi operator - (mazi other){
return mazi(x + other.y, y - other.x);
}
bool operator < (const mazi other) const {
if (x < other.x) return true;
if (x == other.x && y < other.y) return true;
return false;
}
bool operator == (const mazi other) const {
return (x == other.x && y == other.y);
}
};
map<mazi, bool> exista;
vector<mazi> puncte;
mazi medie(mazi a, mazi b){
a += b;
return a / 2;
}
bool verif(mazi a, mazi b){
mazi mid = medie(a, b);
mazi dist = medie(a, -b);
if (exista.find(mid - dist) == exista.end()) return false;
if (exista.find(mid - (-dist)) == exista.end()) return false;
return true;
}
int main(){
int n; cin >> n;
for(int i = 0; i < n; i++){
double x, y; cin >> x >> y;
puncte.push_back(mazi((long long) (x * MULT + EPS), (long long) (y * MULT + EPS)));
}
int ans = 0;
for(int i = 0; i < puncte.size(); i++){
for(int j = 0; j < i; j++){
ans += verif(puncte[i], puncte[j]);
}
exista[puncte[i]] = true;
}
cout << ans << endl;
return 0;
}