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

大牛帮忙看看啊!(内有code)

Posted by caizhicong0503 at 2007-03-21 18:52:27 on Problem 1118
In Reply To:为什么会TLE?已经是O(n^2logn)的了啊! Posted by:caizhicong0503 at 2007-03-19 21:53:24
> #include<iostream>
> #include<algorithm> 
> #include<cmath>
> const double Pi=100000000;
> using namespace std;
> struct
> {
> 	double x,y;
> }d[701];
> int main()
> {
> 	int n,i,j,Max;
> 	double p[701];
> 	while(cin >> n,n!=0){
> 		for(i=0;i<n;i++)	cin >> d[i].x >> d[i].y;
> 		Max=1;
> 		for(i=0;i<n;i++)
> 		{
> 			int k=0;
> 			for(j=0;j<n;j++)
> 			{
> 				if(j==i)	continue;
> 				if(d[j].x!=d[i].x)	p[k++]=(d[j].y-d[i].y)/(d[j].x-d[i].x);
> 				else	p[k++]=Pi;
> 			}	
> 			sort(p,p+k);
> 			int t=1;
> 			for(j=1;j<k;j++){
> 				if(p[j]==p[j-1])	t++;
> 				else{
> 					if(Max<t)	Max=t;
> 					t=1;
> 				}
> 			}
> 		}
> 		cout << Max+1 << endl;
> 	}
> }

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