Cod sursa(job #343719)

Utilizator Alexa_ioana_14Antoche Ioana Alexandra Alexa_ioana_14 Data 26 august 2009 23:07:15
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.89 kb
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 1001
struct trapez{long long x,y;}v[N];
short int n;
long long y,yp,x,xp;
long long num=0;
/*bool compar(const trapez&a,const trapez&b)
{
	if (a.x<b.x)
		return true;
	if (a.x==b.x)
		if (a.y<b.y)
			return true;
	return false;
}*/
void citire()
{
	freopen("trapez.in","r",stdin);
	freopen("trapez.out","w",stdout);
	scanf("%hd",&n);
	for (short int i=1; i<=n; ++i)
		scanf("%lld%lld",&v[i].x,&v[i].y);
	//sort(v+1,v+1+n,compar);
}
void gasesc()
{
	for (int i=1; i<=n; ++i)
	{
		for (int j=i+1; j<=n; ++j)
		{
			y=v[j].y-v[i].y;
			x=v[i].x-v[j].x;
			for (int k=j+1; k<=n; ++k)
			{
				for (int h=k+1; h<=n; ++h)
				{
					yp=v[h].y-v[k].y;
					xp=v[k].x-v[h].x;
					if (y/yp==x/xp)
						++num;
				}
			}
		}
	}
	printf("%lld",num);
}
int main()
{
	citire();
	gasesc();
	return 0;
}