Pagini recente » Cod sursa (job #145665) | Cod sursa (job #2643465) | Cod sursa (job #293077) | Cod sursa (job #1713163) | Cod sursa (job #2100322)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#define EPS 1e-3
using namespace std;
ifstream si("triang.in");
ofstream so("triang.out");
struct pct
{
long double x,y,lg,u;
} v[1505],c[1505];
inline long double dist2(pct a,pct b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
inline bool cmp(pct a,pct b)
{
if(fabs(a.lg-b.lg)<EPS)
return (a.u<b.u);
return a.lg<b.lg;
}
int main()
{
int n;
si>>n;
for(int i=1;i<=n;++i)
{
si>>v[i].x>>v[i].y;
}
int ans=0;
for(int i=1;i<=n;++i)
{
int m=0;
for(int j=1;j<i;++j)
{
c[++m]=v[ j ];
c[m].lg=dist2(v[i],v[j]);
c[m].u=atan2(v[j].y-v[i].y,v[j].x-v[i].x);
}
sort(c+1,c+m+1,cmp);
int k=1;
for(int j=1;j<=m;++j)
{
while(k<j&&c[j].lg-c[k].lg>EPS)
++k;
while(k<j&&fabs(c[j].lg-c[k].lg)<EPS&&dist2(c[k],c[j])-c[j].lg>EPS)
++k;
if(k<j&&fabs(c[j].lg-c[k].lg)<EPS&&fabs(dist2(c[k],c[j])-c[j].lg)<EPS)
{
++ans;
}
}
}
so<<ans<<'\n';
return 0;
}