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
",ans/(pi*2.0));

  }
  return 0;
}
原文地址:https://www.cnblogs.com/13224ACMer/p/4693054.html