Pagini recente » Cod sursa (job #2427795) | Cod sursa (job #3195711) | Cod sursa (job #2341511) | Cod sursa (job #2478579) | Cod sursa (job #3004541)
/*****
░██████╗░█████╗░░█████╗░███╗░░██╗████████╗
██╔════╝██╔══██╗██╔══██╗████╗░██║╚══██╔══╝
╚█████╗░██║░░╚═╝███████║██╔██╗██║░░░██║░░░
░╚═══██╗██║░░██╗██╔══██║██║╚████║░░░██║░░░
██████╔╝╚█████╔╝██║░░██║██║░╚███║░░░██║░░░
╚═════╝░░╚════╝░╚═╝░░╚═╝╚═╝░░╚══╝░░░╚═╝░░░
*****/
#include <iostream>
#include <math.h>
#include <fstream>
#include <iomanip>
#include <algorithm>
using namespace std;
#define PI 3.1415
#define eps 0.001
ifstream fin("triang.in");
ofstream fout("triang.out");
int N,cnt;
const double sin60=sqrt(3.0/4);
const double cos60=1.0/2.0;
void fastread(){
ios_base::sync_with_stdio(false);
fin.tie(NULL);
}
struct Punct{
double x,y;
}p[1505];
bool cmp(Punct p1,Punct p2){
if(p1.x==p2.x)
return p1.y<p2.y;
return p1.x<p2.x;
}
int cb(Punct C){
int st=1,dr=N;
while(st<=dr){
int mij=(st+dr)/2;
if(abs(p[mij].x-C.x)<=eps && abs(p[mij].y-C.y)<=eps)
return 1;
else {if(p[mij].x<C.x)
st=mij+1;
else dr=mij-1;
}
}
return 0;
}
void solve(Punct a, Punct b)
{
double dist=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
Punct mj={(a.x+b.x)/2,(a.y+b.y)/2};
double cosX=(b.x-a.x)/dist;
double sinX=(b.y-a.y)/dist;
double dy= dist*sin60*cosX;
double dx= dist*sin60*sinX;
Punct c={mj.x+dx,mj.y-dy};
Punct d={mj.x-dx,mj.y+dy};
if(cb(c))
cnt++;
if(cb(d))
cnt++;
}
int main(){
fastread();
fin>>N;
for(int i=1;i<=N;i++)
{
fin>>p[i].x>>p[i].y;
}
sort(p+1,p+N+1,cmp);
for(int i=1;i<N;i++)
{
for(int j=i+1;j<=N;j++)
{
solve(p[i],p[j]);
}
}
fout<<cnt/3;
return 0;
}