Pagini recente » Cod sursa (job #1582319) | Cod sursa (job #470668) | Cod sursa (job #2518657) | Cod sursa (job #2193461) | Cod sursa (job #2602565)
#include <iostream>
#include <fstream>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>
#define PI 3.14159265
const int MAXN = 1e4 + 5;
using namespace std;
ifstream in("triang.in");
ofstream out("triang.out");
typedef long double ld;
pair<ld,ld> v[MAXN];
int n;
int cautbinar(ld x,ld y){
int pas = 1<<10, r = 0;
while(pas){
if(r + pas <= n && (v[r + pas].first < x || (abs(v[r + pas].first - x) <= 1e-3 && abs(y - v[r + pas].second) <= 1e-3))){
r += pas;
}
pas /= 2;
}
return r;
}
int main()
{
in>>n;
for(int i = 1; i <= n; i++){
ld x,y;
in>>x>>y;
v[i] = {x,y};
}
sort(v + 1,v + n + 1);
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = i + 1; j <= n; j++){
ld difx = v[j].first - v[i].first;
ld dify = v[j].second - v[i].second;
ld unghi = PI / 3;
ld rotx = difx * cos(unghi) - dify * sin(unghi);
ld roty = difx * sin(unghi) + dify * cos(unghi);
ld x = v[i].first + rotx,y = v[i].second + roty;
int index = cautbinar(x,y);
pair<ld,ld>gasit = v[index];
if(j < index && abs(gasit.first - x) < 1e-3 && abs(gasit.second - y) < 1e-3){
ans++;
}
unghi = - PI / 3;
rotx = difx * cos(unghi) - dify * sin(unghi);
roty = difx * sin(unghi) + dify * cos(unghi);
x = v[i].first + rotx,y = v[i].second + roty;
index = cautbinar(x,y);
gasit = v[index];
if(j < index && abs(gasit.first - x) < 1e-3 && abs(gasit.second - y) < 1e-3){
ans++;
}
}
}
out<<ans;
return 0;
}