Cod sursa(job #763565)

Utilizator lucian666Vasilut Lucian lucian666 Data 2 iulie 2012 16:45:41
Problema Trapez Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.89 kb


#include<fstream>
#include<algorithm>
#define INF 0x3f3f3f3f


using namespace std;
ofstream out("trapez.out");


struct punct
{
	long long  x,y;
};
punct v[1001];


int n,m;
double v1[1000005];

void citire();

void solve();

int main()
{
	citire();
	solve();
	return 0;
}
void citire()
{
	ifstream in("trapez.in");
	in>>n;
	for(int i=1;i<=n;i++)
		in>>v[i].x>>v[i].y;
}

void solve()
{
	double panta;
	int i,j,rez1=0;
	for(i=1;i<n;i++)
		for(j=i+1;j<=n;j++)
		{
			if(v[i].x==0&&v[j].x==0)
				panta=INF;
				else
				panta=(double) (double(v[j].y-v[i].y)/(double(v[j].x-v[i].x)));
				
				v1[++m]=panta;
		}
			sort(v1+1,v1+m+1);
			
			int rez=0,nrc=1;
			for(i=1;i<m;i++)
			if(v1[i]==v1[i+1])
				++nrc;
			else
			{
				rez=rez+(nrc)*(nrc-1)/2;
				nrc=1;
			}
			if(nrc>=2)
				rez=rez+(nrc)*(nrc-1)/2;
			
				out<<rez<<'\n';
}