Pagini recente » Cod sursa (job #3229941) | Cod sursa (job #722555) | Cod sursa (job #2849399) | Cod sursa (job #2688568) | Cod sursa (job #2250933)
#include <fstream>
#include <map>
#include <algorithm>
#define COS 0.5
#define SIN 0.86602540378
#define VAL 1505
#define EPS 0.0001
using namespace std;
ifstream fin("triang.in");
ofstream fout("triang.out");
int N, i, j, ANS;
double X, Y, X1, Y1;
pair <double, double> P[VAL];
double MODUL(double X)
{
return max(X, -X);
}
int Cautbin(double X, double Y)
{
int poz=0, i, nr;
for (i=10; i>=0; i--)
{
nr=poz+(1 << i);
if (nr<=N)
{
if (MODUL(P[nr].first-X)<=EPS && MODUL(P[nr].second-Y)<=EPS)
return 1;
if (P[nr].first<X || (P[nr].first==X && P[nr].second<Y))
poz=nr;
}
}
if (MODUL(P[poz].first-X)<=EPS && MODUL(P[poz].second-Y)<=EPS)
return 1;
return 0;
}
int main()
{
fin >> N;
for (i=1; i<=N; i++)
fin >> P[i].first >> P[i].second;
sort(P+1, P+N+1);
for (i=1; i<=N; i++)
{
for (j=1; j<=N; j++)
{
/*X=P[i].first-P[j].first;
Y=P[i].second-P[j].second;
X1=X*COS-Y*SIN;
Y1=X*SIN+Y*COS;
X1+=P[j].first;
Y1+=P[j].second;
ANS+=Cautbin(X1, Y1);
X=P[j].first-P[i].first;
Y=P[j].second-P[i].second;
X1=X*COS-Y*SIN;
Y1=X*SIN+Y*COS;
X1+=P[i].first;
Y1+=P[i].second;
ANS+=Cautbin(X1, Y1);*/
X=(P[i].first+P[j].first) / 2;
Y=(P[i].second+P[j].second) / 2;
X1=X+(COS*(P[j].second-P[i].second));
Y1=Y+(COS*(P[i].first-P[j].first));
//fout << X1 << " " << Y1 << '\n';
ANS+=Cautbin(X1, Y1);
X1=X+(COS*(P[i].second-P[j].second));
Y1=Y+(COS*(P[j].first-P[i].first));
ANS+=Cautbin(X1, Y1);
//fout << X1 << " " << Y1 << '\n';
}
}
fout << ANS / 6 << '\n';
fin.close();
fout.close();
return 0;
}