Cod sursa(job #345843)

Utilizator Alexa_ioana_14Antoche Ioana Alexandra Alexa_ioana_14 Data 4 septembrie 2009 23:37:00
Problema Triang Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include<cstdio>
#include<algorithm>
#define N 15001
//#define M 2000
#define M 37507501
using namespace std;
const double eps=1e-3;
struct triang{double x,y;}v[N];
short int n;
int num;
double a[M];
/*bool compar(const double &a,const double&b)
{
	return a+eps<b;
}*/
void citire()
{
	freopen("triang.in","r",stdin);
	freopen("triang.out","w",stdout);
	scanf("%hd",&n);
	for (short int i=1; i<=n; ++i)
	{
		scanf("%lf",&v[i].x);
		scanf("%lf",&v[i].y);
	}
}
void numar()
{
	double ab,bc,ac;
	int num=0;
	for (int i=1; i<n-1; ++i)
		for (int j=i+1; j<n; ++j)
		{
			ab=(v[i].x-v[j].x)*(v[i].x-v[j].x)+(v[i].y-v[j].y)*(v[i].y-v[j].y);
			for (int k=j+1; k<=n; ++k)
			{
				bc=(v[j].x-v[k].x)*(v[j].x-v[k].x)+(v[j].y-v[k].y)*(v[j].y-v[k].y);
				ac=(v[i].x-v[k].x)*(v[i].x-v[k].x)+(v[i].y-v[k].y)*(v[i].y-v[k].y);
				if (ab+eps>=bc&&ac+eps>=bc)
					++num;
			}
		}
	printf("%d",num);
}
int main()
{
	citire();
	numar();
	return 0;
}