三分。

 #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. Array数组基本案例:图书基本录入输出系统

    import java.util.Scanner; public class ArrayTest{ public static void main(String args[]){ Scanner sc ...

  2. fluentd结合kibana、elasticsearch实时搜索分析hadoop集群日志<转>

    转自 http://blog.csdn.net/jiedushi/article/details/12003171 Fluentd是一个开源收集事件和日志系统,它目前提供150+扩展插件让你存储大数据 ...

  3. JavaScript--动态更改CSS样式

    JavaScript太强大了,虽然是弱语言,不过一点都不输于Java 可以自行设置随机数,来动态更改CSS样式,每一次都是不一样的感觉,这个小功能挺实用的 <!DOCTYPE html> ...

  4. 网页调用外部APP

    <activity android:name=".MainActivity" android:label="@string/app_name"> & ...

  5. MySql Connector/Net Mysql like 搜索中文的问题(c#和asp.net连接mysql)

    Connector/Net 6.9.8 选择.net/mono即可,不需要安装. 将对应版本的MySql.Data.dll复制到bin目录下即可使用 http://dev.mysql.com/down ...

  6. linux下系统定时任务配置----crontab(mysql定时备份)

    crontab命令用于设置周期性被执行的指令,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动crond进程,crond进程每分钟会定期检查是否有要执行的任 ...

  7. (Error) The type AESKeyGenerator is not accessible due to restriction on required library.

    error for 'Access restriction: The type AESKeyGenerator is not accessible due to restriction on requ ...

  8. 在Cognos报表中使用钻取特性,参数传递

    转载至:http://blog.sina.com.cn/s/blog_6eda1c4e0100mu3t.html Cognos的钻取方式大致可以分为三种: 1.模型固有的->由CUBE和DMR支 ...

  9. XML 标记使用的特殊字符对应内置实体

    下表为 XML 标记使用的字符列出了五种内置实体.   实体 实体引用 含义 lt < <(小于号) gt > >(大于号) amp & &(“and”符) a ...

  10. Spring 环境搭建

    1.导包 2.编写Helloworld程序 package cn.test.helloWorld; public class HelloWorld { public void sayHello(){ ...