三分。

 #include <cstdio>
#include <cstring>
#include <cmath> typedef struct {
double x, y;
} Point_t; Point_t A, B, C, D;
const double eps = 1.0e-8;
double P, Q, R; double dist(Point_t a, Point_t b) {
return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
} double t_ab(Point_t a, Point_t b) {
return dist(a, b)/P;
} double t_cd(Point_t c, Point_t d) {
return dist(c, d)/Q;
} double t_oth(Point_t x, Point_t y) {
return dist(x, y)/R;
} double tri_cd(Point_t c, Point_t d, Point_t S) {
Point_t left = c, right = d;
Point_t p1, p2; while (dist(left, right) > eps) {
p1.x = left.x*2.0/3.0 + right.x/3.0;
p1.y = left.y*2.0/3.0 + right.y/3.0;
p2.x = left.x/3.0 + right.x*2.0/3.0;
p2.y = left.y/3.0 + right.y*2.0/3.0;
if (t_oth(S, p1)+t_cd(p1, D) <= t_oth(S, p2)+t_cd(p2, D)) {
right = p2;
} else {
left = p1;
}
}
return t_oth(S, left) + t_cd(left, d);
} double tri_ab(Point_t a, Point_t b) {
Point_t left = a, right = b;
Point_t p1, p2; while (dist(left, right) > eps) {
p1.x = left.x*2.0/3.0 + right.x/3.0;
p1.y = left.y*2.0/3.0 + right.y/3.0;
p2.x = left.x/3.0 + right.x*2.0/3.0;
p2.y = left.y/3.0 + right.y*2.0/3.0;
if (t_ab(a, p1)+tri_cd(C, D, p1) <= t_ab(a, p2)+tri_cd(C, D, p2)) {
right = p2;
} else {
left = p1;
}
}
return t_ab(a, left) + tri_cd(C, D, left);
} int main() {
int t; scanf("%d", &t);
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);
printf("%.2lf\n", tri_ab(A, B));
} return ;
}

【HDOJ】3400 Line belt的更多相关文章

  1. HDU 3400 Line belt (三分再三分)

    HDU 3400 Line belt (三分再三分) ACM 题目地址:  pid=3400" target="_blank" style="color:rgb ...

  2. 三分套三分 --- HDU 3400 Line belt

    Line belt Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=3400 Mean: 给出两条平行的线段AB, CD,然后一 ...

  3. 搜索(三分):HDU 3400 Line belt

    Line belt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  4. HDU 3400 Line belt (三分嵌套)

    题目链接 Line belt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  5. HDU 3400 Line belt【三分套三分】

    从A出发到D,必定有从AB某个点E出发,从某个点F进入CD 故有E,F两个不确定的值. 在AB上行走的时间   f = AE / p 在其他区域行走的时间 g = EF / r 在CD上行走的时间   ...

  6. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  7. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

  8. 【HDOJ】4328 Cut the cake

    将原问题转化为求完全由1组成的最大子矩阵.挺经典的通过dp将n^3转化为n^2. /* 4328 */ #include <iostream> #include <sstream&g ...

  9. 【HDOJ】3553 Just a String

    后缀数组加二分可解. /* 3553 */ #include <iostream> #include <sstream> #include <string> #in ...

随机推荐

  1. Swift-Lesson2(下)

  2. YYCache 源码分析(一)

    iOS 开发中总会用到各种缓存,YYCache或许是你最好的选择.性能上有优势,用法也很简单.作者ibireme曾经对比过同类轮子:http://blog.ibireme.com/2015/10/26 ...

  3. JAVA IDE基本操作常识

    快捷键: Ctrl+/   选中区单行注释和 取消 选中区单行注释和 Alt + / 代码辅助 shift + Ctrl +/ 选中区多行注释 shift + Ctrl +\ 取消选中区多行注释 Ct ...

  4. PHP: 深入pack/unpack <转> [链接]

    PHP: 深入pack/unpack PHP: chr和pack.unpack那些 PHP: pack/unpack补遗

  5. xUtils3源码分析(一):view的绑定

    概述 xUtils3是国人开发的一款功能丰富的Android快速开发框架,值得研究下.zip包下载:[ZIP]xutils主要分以下几个模块 视图绑定模块 网络请求模块 数据库模块 图片加载模块 我们 ...

  6. ORACLE 数据库总结

    1.表和数据恢复 1.从回收站里查询被删除的表 select object_name,original_name,partition_name,type,ts_name,createtime,drop ...

  7. "javascript:void(0)"用法

    1.window.open(''url'') 2.用自定义函数 <script> function openWin(tag,obj) { obj.target="_blank&q ...

  8. 在Global.asax文件里实现通用防SQL注入漏洞程序(适应于post/get请求)

    可使用Global.asax中的Application_BeginRequest(object sender, EventArgs e)事件来实现表单或者URL提交数据的获取,获取后传给SQLInje ...

  9. Oracle NULLIF函数

    Oracle NULLIF函数 Oracle NULLIF函数语法为NULLIF(表达式1,表达式2),如果表达式1和表达式2相等则返回空值,如果表达式1和表达式2不相等则返回表达式1的结果. 注意: ...

  10. 【转】 分析iOS Crash文件:符号化iOS Crash文件的3种方法

    当你的应用提交到AppStore或者各个渠道之后,请问你多久会拿到crash文件?你如何分析crash文件的呢? 上传crash文件 你的应用应当有模块能够在应用程序crash的时候上传crash信息 ...