Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
全过了还WA附代码In Reply To:做成SB的孩子留组官方数据。。。 Posted by:wizmann at 2011-07-09 19:33:30 #include <iostream> //#include <fstream> #include <iomanip> using namespace std; int n; double a[41],b[41],c[41],d[41]; struct point { double x,y; }; point p1,p2,p3,p4,x1,x2,x3,x4; double ans; #define eps 1.0e-8 point intersect(point a,point b,point c,point d) { point p; if(abs(c.x-d.x)>eps) { double e1=(b.y-a.y)/(b.x-a.x)-(c.y-d.y)/(c.x-d.x); double e2=c.y-b.y+b.x*(b.y-a.y)/(b.x-a.x)-c.x*(c.y-d.y)/(c.x-d.x); p.x=e2/e1; p.y=(b.y-a.y)/(b.x-a.x)*(p.x-b.x)+b.y; } else{ p.x=c.x; p.y=(b.y-a.y)/(b.x-a.x)*(p.x-b.x)+b.y; } return p; } double sur(point a,point b,point c,point d) { double s1=0.5*abs((p2.x-p1.x)*(p4.y-p1.y)-(p2.y-p1.y)*(p4.x-p1.x)); double s2=0.5*abs((p3.x-p2.x)*(p4.y-p3.y)-(p3.y-p2.y)*(p4.x-p3.x)); return s1+s2; } int main() { //ofstream fout("a.txt"); while(cin>>n&&n) { for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) cin>>b[i]; for(int i=1;i<=n;i++) cin>>c[i]; for(int i=1;i<=n;i++) cin>>d[i]; c[0]=a[0]=b[0]=d[0]=0; a[n+1]=b[n+1]=c[n+1]=d[n+1]=1; ans=0; for(int i=1;i<=n+1;i++) for(int j=1;j<=n+1;j++) { x1.x=0;x1.y=c[i-1];x2.x=1;x2.y=d[i-1]; x3.x=b[j-1];x3.y=1;x4.x=a[j-1];x4.y=0; p1=intersect(x1,x2,x3,x4); x1.x=0;x1.y=c[i]; x2.x=1;x2.y=d[i]; x3.x=b[j-1];x3.y=1;x4.x=a[j-1];x4.y=0; p2=intersect(x1,x2,x3,x4); x1.x=0;x1.y=c[i]; x2.x=1;x2.y=d[i]; x3.x=b[j];x3.y=1;x4.x=a[j];x4.y=0; p3=intersect(x1,x2,x3,x4); x1.x=0;x1.y=c[i-1]; x2.x=1;x2.y=d[i-1]; x3.x=b[j];x3.y=1;x4.x=a[j];x4.y=0; p4=intersect(x1,x2,x3,x4); ans=max(ans,sur(p1,p2,p3,p4)); } cout<<fixed<<setprecision(6)<<ans<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator