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

高手一定要看啊,我都愁死了,虽然是N^3的,可就是wa,哪错了啊

Posted by rcrt10 at 2009-06-20 23:48:06 on Problem 2606
#include<iostream>
using namespace std;
struct rabbit
{
	int x;
	int y;
};
bool line(rabbit a,rabbit b,rabbit c)
{
	if((b.x==a.x&&b.x==a.x)||(b.y==a.y&&b.y==c.y))
		return true;
	if((b.y-a.y)*(c.x-a.x)==(c.y-a.y)*(b.x-a.x))
		return true;
	else 
		return false;
}
int main()
{
	int max=0;
	rabbit rab[200];
	int n=0;
	int i;
	int j,k,m;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>rab[i].x>>rab[i].y;
	}
	for(j=0;j<n-2;j++)
	{	   	
		for(k=j+1;k<n-1;k++)
		{
			int max2=2;
			for(m=k+1;m<n;m++)
			{
				if(line(rab[j],rab[k],rab[m]))
					max2++;
			}
			if(max2>max)
			    max=max2;
		}
	}
	cout<<max<<endl;
	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