Cod sursa(job #499970)

Utilizator hadesgamesTache Alexandru hadesgames Data 11 noiembrie 2010 09:58:42
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.06 kb
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
#define fi first
#define se second
#define mp make_pair

FILE *in,*out;

map < pair<int,int> ,int > hash;
int x[1005],y[1005];
inline int abs(int x)
{
	return x<0?-x:x;
}
int cmmdc(int x,int y)
{
	if (!y)
		return x;
	return cmmdc(y,x%y);
}
int main()
{
	int n,i,j,a,b,cntox=0,cntoy=0,rez=0,d;
	map<pair<int,int>,int>::iterator it;
	in=fopen("trapeze.in","r");
	out=fopen("trapeze.out","w");
	fscanf(in,"%d",&n);
	return 0;
	for (i=1;i<=n;i++)
		fscanf(in,"%d%d",&x[i],&y[i]);
	for (i=1;i<=n;i++)
			for (j=i+1;j<=n;j++)
			{
				if (x[i]==x[j])
				{
					cntoy++;
					continue;
				}
				if (y[i]==y[j])
				{
					cntox++;
					continue;
				}
				d=cmmdc(abs(x[i]-x[j]),abs(y[i]-y[j]));
				a=(y[j]-y[i])/d;
				b=(x[j]-x[i])/d;
				hash[mp(a,b)]++;
			}
	rez=cntox * (cntox-1)/2 + cntoy*(cntoy-1)/2;
	return 0;
	for (it=hash.begin();it!=hash.end();it++)
		rez+=it->se*(it->se-1)/2;
	fprintf(out,"%d\n",rez);
	fclose(in);
	fclose(out);
	return 0;
}