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

RE了好多次不知道怎么回事就过了,141MS

Posted by 864776505 at 2014-09-23 21:10:06 on Problem 1118
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<fstream>
#define N 701
double a[N] = {0};
using namespace std;
struct mypoint
{
	int x;
	int y;
};
int cmp(mypoint a,mypoint b)
{
	return (a.x==b.x && a.y<b.y || a.x <b.x);
}

mypoint aa[701]; 
int main()
{
	freopen("D:\\in.txt","r",stdin);
	int i = 0;
	int n;
	while(scanf("%d",&n) && n)
	{
		int num = 0;
		for(int i = 0;i<n;i++)
		{
			cin>>aa[i].x>>aa[i].y;
		}

		sort(aa,aa+n,cmp);
		int max = 0;
		for(int i = 0;i<n;i++)
		{
			for(int j = i+1;j<n;j++)
			{
				a[num++] = (double)(aa[j].y-aa[i].y)/(aa[j].x-aa[i].x);
			}
			sort(a,a+num);
			int count = 1;
			for(int i = 1;i<num;i++)
			{
				if(a[i]==a[i-1])
					count++;
				else
				{
					count= 1;
				}
				if(count>max)
					max = count;
			}
			num = 0;
		}	
	printf("%d\n",max+1);
	}
	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