#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #include<bitset> #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long #define Pair pair<int,int> const double EPS = 1E-10; const int MOD = 1E9+7; const int N = 10000+5; const int dx[] = {-1,1,0,0,-1,-1,1,1}; const int dy[] = {0,0,-1,1,-1,1,-1,1}; using namespace std; struct Node{ double x,y; Node(){} Node(double x,double y):x(x),y(y){} }a,b,c,d; double p,q,r; double getDis(double x1,double y1,double x2,double y2){ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } double judge(Node e){ Node left(c.x,c.y),right(d.x,d.y); int times=100;//控制三分次数 while(times--){ Node lmid,rmid; lmid.x=left.x+(right.x-left.x)/3; lmid.y=left.y+(right.y-left.y)/3; rmid.x=right.x-(right.x-left.x)/3; rmid.y=right.y-(right.y-left.y)/3; double dis1=getDis(lmid.x,lmid.y,d.x,d.y)/q+getDis(lmid.x,lmid.y,e.x,e.y)/r; double dis2=getDis(rmid.x,rmid.y,d.x,d.y)/q+getDis(rmid.x,rmid.y,e.x,e.y)/r; if(dis1<dis2){ right.x=rmid.x; right.y=rmid.y; } else{ left.x=lmid.x; left.y=lmid.y; } } return getDis(left.x,left.y,d.x,d.y)/q+getDis(left.x,left.y,e.x,e.y)/r+getDis(e.x,e.y,a.x,a.y)/p; } int main(){ scanf("%lf%lf",&a.x,&a.y); scanf("%lf%lf",&b.x,&b.y); scanf("%lf%lf",&c.x,&c.y); scanf("%lf%lf",&d.x,&d.y); scanf("%lf%lf%lf",&p,&q,&r); Node left(a.x,a.y),right(b.x,b.y); int times=100;//控制三分次数 while(times--){ Node lmid,rmid; lmid.x=left.x+(right.x-left.x)/3; lmid.y=left.y+(right.y-left.y)/3; rmid.x=right.x-(right.x-left.x)/3; rmid.y=right.y-(right.y-left.y)/3; if(judge(lmid)<judge(rmid)){ right.x=rmid.x; right.y=rmid.y; } else{ left.x=lmid.x; left.y=lmid.y; } } printf("%.2lf",judge(left)); return 0; }
0.0分
0 人评分
【亲和数】 (C语言代码)浏览:541 |
wu-淘淘的名单 (C++代码)浏览:1532 |
用筛法求之N内的素数。 (C语言代码)浏览:685 |
数对 (C语言代码)浏览:762 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:585 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:755 |
模拟计算器 (C语言代码)浏览:2366 |
C语言训练-大、小写问题 (C语言代码)浏览:719 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:416 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:539 |