Pagini recente » Cod sursa (job #1400429) | Cod sursa (job #1843394) | Cod sursa (job #2838489) | Cod sursa (job #1499324) | Cod sursa (job #2602918)
#include <bits/stdc++.h>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
typedef long double ld;
ifstream f("triang.in");
ofstream g("triang.out");
int n,ans=0;
struct punct
{
ld x,y;
} a,b,c;
vector <pair<ld,ld>> v;
void cautare(ld x,ld y)
{
int r=0;
for(int p=28; p>=0; p--)
if(r+(1<<p)<=n and (v[r+(1<<p)].first<x or ((abs(v[r+(1<<p)].first - x) <= 0.001 and abs(v[r+(1<<p)].second-y) <= 0.001))))
r+=(1<<p);
// cout<<setprecision(7)<<fixed<<x<<" "<<y<<endl;
// cout<<x<<" "<<y<<endl;
if(abs(v[r].first - x) <= 0.001 and abs(v[r].second-y) <= 0.001){
ans++;
}
}
int main()
{
f>>n;
for(int i=1; i<=n; i++)
{
ld x,y;
f>>x>>y;
v.push_back({x,y});
}
ld radical3 = sqrt(3);
sort(v.begin(),v.end());
for(int i=0; i<v.size()-2; i++){
for(int j=i+1; j<v.size()-1; j++)
{
a.x=v[i].first;
a.y=v[i].second;
b.x=v[j].first;
b.y=v[j].second;
c.x=a.x+(b.x-a.x)/2-((b.y-a.y)*radical3)/2;
c.y=a.y+((b.x-a.x)*radical3)/2+(b.y-a.y)/2;
punct d;
d.x=a.x+(b.x-a.x)/2+((b.y-a.y)*radical3)/2;
d.y=a.y-((b.x-a.x)*radical3)/2+(b.y-a.y)/2;
cautare(c.x,c.y);
cautare(d.x,d.y);
}
}
g<<ans;
return 0;
}