Pagini recente » Cod sursa (job #3149052) | Cod sursa (job #2362004) | Cod sursa (job #1457538) | Istoria paginii runda/001./clasament | Cod sursa (job #2779045)
#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 >> v[i].x >> v[i].y;
}
cnt = 0;
for ( int i = 1; i <= n; ++i ) {
for ( int j = 1; j < i; ++j ) {
p = get_point1(i, j);
if ( s.find(get_point1(i, j)) != s.end() ) {
++cnt;
}
}
s.insert( v[i] );
}
fout << cnt;
fin.close();
fout.close();
return 0;
}