Cod sursa(job #351079)

Utilizator Anamaria20Cotirlea Anamaria Anamaria20 Data 26 septembrie 2009 19:16:55
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.14 kb
#include <stdio.h>
#include <algorithm>

using namespace std;

FILE *f,*s;

int n,i,j,k,l;

struct punct
{
	int x;
	int y;
};

punct v1[1005],v2[1005];

int cmp(punct a, punct b)
{
	if(a.x!=b.x)
		return a.x<b.x;
	else
		return a.y<b.y;
}	

int main()
{
	f=fopen("trapez.in","r");
	s=fopen("trapez.out","w");
	
	fscanf(f,"%d",&n);
	
	for(i=1;i<=n;i++)
		fscanf(f,"%d %d",&v1[i].x,&v1[i].y);
	/*
	k=1;
	for(i=1;i<n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			v2[k].x=v1[i].x-v1[j].x;
			v2[k].y=v1[i].y-v1[j].y;
			
			if(v2[k].x<0)
				v2[k].x*=-1;
			
			if(v2[k].y<0)
				v2[k].y*=-1;
			
			
			
			while(v2[k].x%2==0 && v2[k].y%2==0 && v2[k].x>0 && v2[k].y>0)
			{
				v2[k].x/=2;
				v2[k].y/=2;
			}  
			
			for(l=3;l<=v2[k].x&&l<=v2[k].y;l+=2)
			{
				while(v2[k].x%l==0 && v2[k].y%l==0 && v2[k].x>0 && v2[k].y>0)
				{
					v2[k].x/=l;
					v2[k].y/=l;
				}  
			}   
			
			k++;
		}
	}	
	
	k--;
	
	sort(v2+1,v2+k+1,cmp);
	
	int rez=0;
	for(i=2;i<=k;i++)
	{
		if(v2[i].x==v2[i-1].x && v2[i].y==v2[i-1].y)
			rez++;
	}	
		
	fprintf(s,"%d",rez);
	*/
	fclose(s);
	
	return 0;
}