Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 698 Accepted Submission(s): 243
1 0 0 0 100 100 0 100 100 2 2 1
136.60先对AB段三分一次,在对CD三分一次。。。一直循环#include <iostream> #include <math.h> using namespace std; #define EPS 1e-10 struct point { double x,y; }; point A,B,C,D,aa,bb,low1,high1,low2,high2,mid1,mid2,mid3,mid4; double P,Q,R; double lenth(point a,point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } bool judge1(point x1,point x2) { if((lenth(A,x1)/P+lenth(x1,bb)/R+lenth(bb,D)/Q)>=(lenth(A,x2)/P+lenth(x2,bb)/R+lenth(bb,D)/Q)) return true; else return false; } bool judge2(point x1,point x2) { if((lenth(A,aa)/P+lenth(aa,x1)/R+lenth(x1,D)/Q)>=(lenth(A,aa)/P+lenth(aa,x2)/R+lenth(x2,D)/Q)) return true; else return false; } void san_fen1(); void san_fen2(); int main() { int t; while(scanf("%d",&t)!=EOF) { while(t--) { scanf("%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y); scanf("%lf%lf%lf%lf",&C.x,&C.y,&D.x,&D.y); scanf("%lf%lf%lf",&P,&Q,&R); aa=A; bb=D; low1=A; high1=B; low2=C; high2=D; if(R>=P && R>=Q) { printf("%.2lf/n",lenth(A,D)/R); continue; } san_fen1(); printf("%.2lf/n",lenth(A,low1)/P+lenth(low1,low2)/R+lenth(low2,D)/Q); } } return 0; } void san_fen1() { while (lenth(low1,high1)>EPS) { mid1.x=(2*low1.x+high1.x)/3; mid1.y=(2*low1.y+high1.y)/3; mid2.x=(low1.x+2*high1.x)/3; mid2.y=(low1.y+2*high1.y)/3; if(judge1(mid1,mid2)) low1=mid1; else high1=mid2; aa.x=(low1.x+high1.x)/2; aa.y=(low1.y+high1.y)/2; san_fen2(); } while (lenth(low2,high2)>EPS) { mid3.x=(2*low2.x+high2.x)/3; mid3.y=(2*low2.y+high2.y)/3; mid4.x=(low2.x+2*high2.x)/3; mid4.y=(low2.y+2*high2.y)/3; if(judge2(mid3,mid4)) low2=mid3; else high2=mid4; bb.x=(low2.x+high2.x)/2; bb.y=(low2.y+high2.y)/2; } } void san_fen2() { if (lenth(low2,high2)>EPS) { mid3.x=(2*low2.x+high2.x)/3; mid3.y=(2*low2.y+high2.y)/3; mid4.x=(low2.x+2*high2.x)/3; mid4.y=(low2.y+2*high2.y)/3; if(judge2(mid3,mid4)) low2=mid3; else high2=mid4; bb.x=(low2.x+high2.x)/2; bb.y=(low2.y+high2.y)/2; } }