比赛 20110414 评测结果 AWTTTTTTTT
题目名称 数三角形 最终得分 10
用户昵称 Citron酱 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-04-14 11:06:03
显示代码纯文本
#include <fstream>
#include <cmath>

#define I_F "tricount.in"
#define O_F "tricount.out"
#define MAXn 100000
#define P 0.0001

using namespace std;

struct point
{
	long x,y;
};

long n;
point p[MAXn];
long long ans=0;

void Input();
inline long long Sqr(long);
inline double Len(point,point);
inline double Tria(double,double,double);
inline double Abs(double);
void Search();
void Output();

int main()
{
	Input();
	Search();
	Output();
	return 0;
}

void Input()
{
	ifstream fin(I_F);
	fin>>n;
	for (long i=0; i<n; i++)
		fin>>p[i].x>>p[i].y;
	fin.close();
}

inline long long Sqr(long x)
{
	return x*x;
}

inline double Len(point a, point b)
{
	return sqrt((double)(Sqr(a.x-b.x)+Sqr(a.y-b.y)));
}

inline double Tria(double a, double b, double c)
{
	double p=(a+b+c)/2;
	return sqrt(p*(p-a)*(p-b)*(p-c));
}

inline double Abs(double x)
{
	return (x>0)?x:(-x);
}

void Search()
{
	point O;
	O.x=O.y=0;
	for (long i=0; i<n; i++)
		for (long j=i+1; j<n; j++)
			for (long k=j+1; k<n; k++)
				if (Abs(Tria(Len(p[i],p[j]),Len(p[j],p[k]),Len(p[k],p[i]))-
						Tria(Len(p[i],p[j]),Len(p[i],O),Len(p[j],O))-
						Tria(Len(p[j],p[k]),Len(p[j],O),Len(p[k],O))-
						Tria(Len(p[k],p[i]),Len(p[k],O),Len(p[i],O)))<=P)
					ans++;
}

void Output()
{
	ofstream fout(O_F);
	fout<<ans<<'\n';
	fout.close();
}