Pagini recente » Cod sursa (job #3252959) | Cod sursa (job #2052278) | Cod sursa (job #3148399) | Cod sursa (job #3159063) | Cod sursa (job #2779043)
#include <fstream>
#include <iostream>
#include <cmath>
#include <set>
using namespace std;
ifstream fin( "triang.in" );
ofstream fout( "triang.out" );
const int MAXN = 1501;
const double cos60 = 0.5;
const double sin60 = sqrt(3) / 2;
const double EPS = 1e-5;
struct pt {
double x, y;
bool operator < ( const pt &a ) const {
if ( a.x - (this -> x) > EPS ) {
return true;
}
if ( a.y - (this -> y) > EPS ) {
return true;
}
return false;
}
};
set<pt> s;
pt v[MAXN];
pt get_point1( int i, int j ) {
pt p1 = v[i], p2 = v[j], ret;
ret.x = cos60 * (p1.x - p2.x) - sin60 * (p1.y - p2.y) + p2.x;
ret.y = sin60 * (p1.x - p2.x) + cos60 * (p1.y - p2.y) + p2.y;
return ret;
}
int main() {
int n, cnt;
pt p;
fin >> n;
for ( int i = 1; i <= n; ++i ) {
fin >> p.x >> p.y;
s.insert(p);
v[i] = p;
}
cnt = 0;
for ( int i = 1; i <= n; ++i ) {
for ( int j = i + 1; j <= n; ++j ) {
p = get_point1(i, j);
if ( s.find(get_point1(i, j)) != s.end() ) {
++cnt;
}
}
}
fout << cnt;
fin.close();
fout.close();
return 0;
}