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 dancia at 2005-03-11 15:27:40 on Problem 1106
#include <stdio.h>
#include <math.h>
#define Pi 3.1415926
double angle[160]={0};

main()
{ 
  int ox,oy,x,y;
  int n,i,j,cnt,max,temp;
  double R;
  scanf("%d %d %lf",&ox,&oy,&R);
  while(R>0){
    scanf("%d",&n);
    cnt=0;
    for(i=0;i<n;i++){
      scanf("%d %d",&x,&y);
      if(sqrt((x-ox)*(x-ox)+(y-oy)*(y-oy))<=R){
         if(x==ox&&y>oy)
           angle[i]=Pi/2;
         if(x==ox&&y<oy)
           angle[i]=Pi/2*3; 
         if(y==oy&&x<ox)
           angle[i]=Pi;
         if(y==oy&&x>ox)
           angle[i]=0;      
         if(x>ox&&y>oy)
           angle[i]=atan((double)(y-oy)/(double)(x-ox));
         if(x>ox&&y<oy)
           angle[i]=2*Pi-atan((double)(oy-y)/(double)(x-ox));
         if(x<ox&&y<oy)
           angle[i]=Pi+atan((double)(oy-y)/(double)(ox-x));
         if(x<ox&&y>oy)
           angle[i]=Pi-atan((double)(y-oy)/(double)(ox-x));
         cnt++;
      }
    }
    max=0;
    for(i=0;i<cnt;i++){
        temp=0;
	for(j=0;j<cnt;j++){
	   if(angle[i]<=Pi){
              if(angle[j]>=angle[i]&&angle[j]<=angle[i]+Pi)
		 temp++;
           }
           else{
             if((angle[j]>=angle[i]&&angle[j]<2*Pi)||(angle[j]>=0&&angle[j]<=angle[i]-Pi))
			  temp++ ;
          }      
       } 
       if(max<temp)
          max=temp;
    }
  printf("%d\n",max);
  scanf("%d %d %lf",&ox,&oy,&R);  
  }
  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