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

用向量叉积来做,不会有浮点误差.

Posted by 00448242 at 2005-07-24 12:01:34 on Problem 1106
In Reply To:这道题有什么陷阱啊??怎么就过不了了?? Posted by:sexboy at 2005-07-24 11:18:24
> #include <iostream>
> #include <cmath>
> #include <algorithm>
> #define pi 3.141592653589793238
> using namespace std;
> int main()
> {
> 	freopen("in.txt","r",stdin);
> 	double x,y,r,ax,ay,temp;
> 	int dot,t,i,j,max,sum,sumofcentre;
> 	while(cin>>x>>y>>r&&r>=0)
> 	{
> 		double node[1000]={0};
> 		cin>>dot;
> 		for(t=sumofcentre=0;dot;--dot)
> 		{
> 			cin>>ax>>ay;
> 			if((ax-x)*(ax-x)+(ay-y)*(ay-y)<=r*r)
> 			{
> 				temp=atan((ay-y)/(ax-x));
> 				if(ax-x>0)
> 				{
> 					if(ay-y>=0)node[t++]=temp;
> 					else node[t++]=2*pi+temp;
> 				}
> 				else if(ax-x==0)
> 				{
> 					if(ay-y>0)node[t++]=pi/2;
> 					else if(ay-y==0)++sumofcentre;
> 					else node[t++]=3*pi/2;
> 				}
> 				else node[t++]=pi+temp;
> 			}
> 		}
> 		sort(node,node+t);
> 		for(i=max=0;i<t-1;++i)
> 		{
> 			for(j=i+1,sum=1+sumofcentre;j<t;++j)
> 			{
> 				if(node[j]-node[i]<=pi)
> 					++sum;
> 				else break;
> 			}
> 			if(sum>max)max=sum;
> 		}
> 		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