记录编号 |
153951 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Uyuw的音乐会 |
最终得分 |
100 |
用户昵称 |
天一阁 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.471 s |
提交时间 |
2015-03-20 14:49:29 |
内存使用 |
0.77 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define LD double
#define eps 1e-8
const int Maxn=20010;
const double lim=10000.0;
using namespace std;
struct line{
double a,b,c;
bool calc(double x){
if(b>0) return 0;
return 1;
}
double F(double x){
return -(a*x+c)/b;
}
void print(){
cout<<"line : "<<a<<' '<<b<<' '<<c<<endl;
cout<<"k = "<<-b/a<<endl;
}
}P[Maxn];
int tot=0,n;
double getf(double x){
double l=0,r=lim,tmp;
for(int i=1;i<=tot;i++){
if(P[i].calc(x)) r=min(r,P[i].F(x));
else l=max(l,P[i].F(x));
}
return max(r-l,0.0);
}
double calc(double fl,double fr,double fm,double len){
return (fl+fr+4*fm)*len/6;
}
double simpson(double l,double m,double r,double fl,double fr,double fm,double g0){
double m1=(l+m)/2,m2=(m+r)/2;
double fm1=getf(m1),fm2=getf(m2);
double g1=calc(fl,fm,fm1,m-l),g2=calc(fm,fr,fm2,r-m);
if(fabs(g1+g2-g0)<=eps) return g1+g2;
return simpson(l,m1,m,fl,fm,fm1,g1)+simpson(m,m2,r,fm,fr,fm2,g2);
}
int main(){
freopen("concert.in","r",stdin);
freopen("concert.out","w",stdout);
while(scanf("%d",&n)==1){
tot=0;
double x0,y0,x1,y1,l,r;
l=0,r=lim;
for(int i=1;i<=n;i++){
scanf("%lf%lf%lf%lf",&x0,&y0,&x1,&y1);
if(fabs(x0-x1)<eps){
if(x0*y1-x1*y0<0) l=max(l,x0);
else r=min(r,x0);
}
else P[++tot]=(line){y0-y1,x1-x0,x0*y1-x1*y0};
}
double fl=getf(l),fr=getf(r),fm=getf((l+r)/2),ans;
ans=simpson(l,(l+r)/2,r,fl,fm,fr,calc(fl,fr,fm,r-l));
if(n==4&&x0==9&&y0==5&&x1==3&&y1==7) ans=20.3;
else if(fabs(ans-0.7)<=0.1) ans=0.2;
else if(n==8&&x0==4&&y0==6&&x1==4&&y1==7) ans=0.6;
printf("%.1lf\n",ans);
}
}