Pagini recente » Cod sursa (job #2107732) | Cod sursa (job #48754) | Cod sursa (job #2169389) | Cod sursa (job #1947688) | Cod sursa (job #2661540)
#include <bits/stdc++.h>
#define ABS(x) ((x) >= 0 ? (x) : -(x))
// https://stackoverflow.com/questions/2861904/how-to-find-coordinates-of-a-2d-equilateral-triangle-in-c
using namespace std;
ifstream fin("triang.in");
ofstream fout("triang.out");
const double eps = 1e-4;
struct punct {
double x, y;
bool operator < (const punct& A) const {
if(ABS(x - A.x) <= eps)
return y + eps <= A.y;
return x + eps <= A.x;
}
};
punct rotire(const punct& A, const punct& B) {
static double c = 0.5, s = sqrt(3) / 2;
double dx = B.x - A.x,
dy = B.y - A.y;
punct C;
C.x = dx * c - dy * s + A.x;
C.y = dx * s + dy * c + A.y;
return C;
}
int main() {
fin.sync_with_stdio(false);
fout.sync_with_stdio(false);
fin.tie(nullptr);
fout.tie(nullptr);
int N;
fin >> N;
set < punct > S;
int ans = 0;
while(N--) {
punct A;
fin >> A.x >> A.y;
for(auto& B : S) {
punct M = rotire(A, B);
if(S.find(M) != S.end())
++ans;
}
S.insert(A);
}
fout << ans;
}