Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

无视精度,1a,代码

Posted by 407811696 at 2011-07-27 12:58:25 on Problem 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define M 205
using namespace std;

struct node
{
	int x;
	int y;
	bool operator<(const node &t)const
	{
		if(x*t.x>0)
		{
			if(y*t.x-x*t.y<0)
				return true;
			else
				return false;
		}
		else
		{
			if(y*t.x-x*t.y<0)
				return false;
			else
				return true;
		}
	}
	bool operator==(const node &t)const
	{
		return y*t.x-x*t.y==0;
	}
};

node a[M*M];
int n,x[M],y[M];

int main()
{
//	freopen("1.txt","r",stdin);
	while(scanf("%d",&n)!=EOF)
	{
		int i,j,k,p;
		int sum;
		for(i=1;i<=n;i++)
			scanf("%d%d",&x[i],&y[i]);
		for(i=1,k=1,p=0;i<=n;i++)
		{
			for(j=i+1;j<=n;j++)
			{
				a[k].x=x[i]-x[j];
				a[k].y=y[i]-y[j];
				if(a[k].x==0)
				{
					p=1;
					continue;
				}
				k++;
			}
		}
		sort(a+1,a+k);
		for(i=2,j=1,sum=1+p;i<k;i++)
		{
			if(!(a[i]==a[j]))
			{
				j=i;
				sum++;
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator