Cod sursa(job #114700)

Utilizator gabitzish1Gabriel Bitis gabitzish1 Data 15 decembrie 2007 15:06:21
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

long n,nr;

long a[5000];

void citire()
{
  long i;

  freopen("trapez.in","r",stdin);
  freopen("trapez.out","w",stdout);
  scanf("%ld",&n);
  long x, y;
  double aux;

  for (i=0; i<n; i++)
  {
	  scanf("%ld %ld",&x, &y);
	  if (x != 0)  aux = (double)y/x;
	  else aux = 90;
	  a[i] =(long)(aux * 100000);
  }


}

int cmp(const void *x, const void *y)
{
	return *(long*)x - *(long*)y;
}

int main()
{
  citire();
  qsort(a,n,sizeof(long),cmp);

  int i, j, contor = 0;
  for (i = 0; i < n; i=i)
  {
	  j = i;
	  while (a[i] == a[j]) j++;
          j--;
	  contor += (((j - i + 1)*(j - i)) / 2);
	  i = j + 1;
  }


  printf("%d",contor);
  return 0;
}