三分。

 #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. Business Analysis and Essential Competencies

    Requirements Classification Schema http://files.cnblogs.com/files/happlyonline/BABOK.pptx http://fil ...

  2. Android Fragment动态添加 FragmentTransaction FragmentManager

    Fragment常用的三个类:android.app.Fragment 主要用于定义Fragmentandroid.app.FragmentManager 主要用于在Activity中操作Fragme ...

  3. 独立硬盘冗余阵列与HDFS

    http://zh.wikipedia.org/wiki/RAID 独立硬盘冗余阵列(RAID, Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列(Re ...

  4. sbt 配置

    1. SBT使用local maven repository,下载的库依然放在 ~/.m2/repository 2. SBT assembly 会把依赖库打包到一个jar包,需要使用assembly ...

  5. Codeforces 540D Bad Luck Island - 概率+记忆化搜索

    [题意] 一个岛上有三种生物A,B,C,各有多少只在输入中会告诉你,每种最多100只 A与B碰面,A会吃掉B, B与C碰面,B会吃掉C, C与A碰面,C会吃掉A...忍不住想吐槽这种环形食物链 碰面是 ...

  6. 循序渐近学docker---笔记

    1.安装docker 环境:ubuntu 16.04 sudo apt-get install docker.io root@ld-Lenovo-G470:~# docker -vDocker ver ...

  7. ASP.NET-FineUI开发实践-16(二)

    实现那还差点,在事件参数里我传了一个boolall选中状态参数,这个参数由前台给的,RowSelect 传的是index 行号,就是改这,通过$符号来分开的, if (commandArgs.Leng ...

  8. Modernizr——为HTML5和CSS3而生!

    原文地址:http://www.alistapart.com/articles/taking-advantage-of-html5-and-css3-with-modernizr/ 堂主译文地址:ht ...

  9. Linq101-Projection

    using System; using System.Linq; namespace Linq101 { class Projection { /// <summary> /// This ...

  10. Effective Java 学习笔记之第七条——避免使用终结(finalizer)方法

    避免使用终结方法(finalizer) 终结方法(finalizer)通常是不可预测的,也是很危险的,一般情况下是不必要的. 不要把finalizer当成C++中析构函数的对应物.java中,当对象不 ...