Pagini recente » Cod sursa (job #1703810) | Cod sursa (job #3211669) | Cod sursa (job #1419615) | Cod sursa (job #1059507) | Cod sursa (job #3148639)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <iomanip>
#include <vector>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
using namespace std;
ifstream fin ("triang.in");
ofstream fout ("triang.out");
typedef long long ll;
const ll Nmax=1500, inf=1e9+5;
const double eps=1e-5;
using pll=pair<ll, ll>;
struct point{
double x, y;
bool operator < ( const point &a ) const {
if ( abs( a.x - (this -> x) ) > eps ) {
return a.x > (this -> x);
}
if ( abs( a.y - (this -> y) ) > eps ) {
return a.y > (this -> y);
}
return false;
}
};
double distsq(point a, point b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int n;
point v[Nmax];
void solve2(double a, double b, double c, double &s1, double &s2){
double d=b*b-4*a*c;
s1=(-b+sqrt(d))/(2*a);
s2=(-b-sqrt(d))/(2*a);
}
void rot(double &a){
a=round(a* 1000.0) / 1000.0;
}
set <point> st;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
fin>>n;
for (int i=0; i<n; i++)
fin>>v[i].x>>v[i].y;
ll sol=0;
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
if (st.find(v[j])!=st.end())
sol++;
double a1, a2, b1, b2;
double x1=-2*v[i].x, y1=-2*v[i].y, z1=v[i].x*v[i].x+v[i].y*v[i].y-distsq(v[i], v[j]),
x2=-2*v[j].x, y2=-2*v[j].y, z2=v[j].x*v[j].x+v[j].y*v[j].y-distsq(v[i], v[j]);
if (x1==x2){
b1=b2=-(z1-z2)/(y1-y2);
solve2(1, x1, b1*b1+y1*b1+z1, a1, a2);
}
else{
double k1=-(y1-y2)/(x1-x2), k2=-(z1-z2)/(x1-x2);
solve2(k1*k1+1, 2*k1*k2+x1*k1+y1, k2*k2+x1*k2+z1, b1, b2);
a1=b1*k1+k2, a2=b2*k1+k2;
}
st.insert({a1, b1});
st.insert({a2, b2});
}
st.clear();
}
fout<<sol;
return 0;
}