UVALive 6324 Archery (求射箭覆盖的期望)

#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
const double pi=3.141592653;
int main(){
  int t;
  scanf("%d",&t);
  while(t--){
    int n;
    scanf("%d",&n);

    double ans=0;

    double x1,y1,x2,y2;

    for(int i=1;i<=n;i++){
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
        double temp=fabs(atan2(y1,x1)-atan2(y2,x2));//atan2,特别注意
        if(temp>pi)
            temp=2.0*pi-temp;
            ans+=temp;
           
        }
      printf("%.5lf\n",ans/(pi*2.0));

  }
  return 0;
}

 

posted @ 2015-07-31 20:08  柳下_MBX  阅读(391)  评论(0编辑  收藏  举报