标签:ble 时间 input 函数 href 整数 输入数据 log int
对于100%的数据,1<= Ax,Ay,Bx,By,Cx,Cy,Dx,Dy<=1000
1<=P,Q,R<=10
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<cmath> #include<map> using namespace std; int ax, ay, bx, by, cx, cy, dx, dy, p, q, r; const double eps = 1e-9; double dis(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } double jisuan(double x1, double y1, double x2, double y2) { return dis(ax, ay, x1, y1) / p + dis(x1, y1, x2, y2) / r + dis(x2, y2, dx, dy) / q; } double solve(double x, double y) { double lx = cx, ly = cy, rx = dx, ry = dy; while (fabs(rx - lx) > eps || fabs(ry - ly) > eps) { double x1 = lx + (rx - lx) / 3, x2 = lx + (rx - lx) / 3 * 2; double y1 = ly + (ry - ly) / 3, y2 = ly + (ry - ly) / 3 * 2; if (jisuan(x, y, x1, y1) > jisuan(x, y, x2, y2)) { lx = x1; ly = y1; } else { rx = x2; ry = y2; } } return jisuan(x, y, lx, ly); } int main() { scanf("%d%d%d%d%d%d%d%d%d%d%d", &ax, &ay, &bx, &by, &cx, &cy, &dx, &dy, &p, &q, &r); double lx = ax, ly = ay, rx = bx, ry = by; while (fabs(rx - lx) > eps || fabs(ry - ly) > eps) { double x1 = lx + (rx - lx) / 3, x2 = lx + (rx - lx) / 3 * 2; double y1 = ly + (ry - ly) / 3, y2 = ly + (ry - ly) / 3 * 2; if (solve(x1, y1) > solve(x2, y2)) { lx = x1; ly = y1; } else { rx = x2; ry = y2; } } printf("%.2lf\n", solve(lx, ly)); return 0; }
标签:ble 时间 input 函数 href 整数 输入数据 log int
原文地址:http://www.cnblogs.com/zbtrs/p/7414113.html