HDU 3400 Line belt (三分嵌套)】的更多相关文章

HDU 3400 Line belt (三分再三分) ACM 题目地址:  pid=3400" target="_blank" style="color:rgb(0,136,204); text-decoration:none">HDU 3400 Line belt 题意:  就是给你两条线段AB , CD .一个人在AB以速度p跑,在CD上以q跑,在其它地方跑速度是r.问你从A到D最少的时间. 分析:  先三分AB上的点.再三分CD上的点就可以. …
题目链接 Line belt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2862    Accepted Submission(s): 1099 Problem Description In a two-dimensional plane there are two line belts, there are two segment…
Line belt Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=3400 Mean: 给出两条平行的线段AB, CD,然后一个人在线段AB的A点出发,走向D点,其中,人在线段AB上的速度为P, 在线段CD上的速度为Q,在其他地方的速度为R,求人从A点到D点的最短时间. analyse: 经典的三分套三分. 首先在AB线段上三分,确定一个点,然后再在CD上三分,确定第二个点,计算出answer.也就是嵌套的三分搜索. Ti…
Line belt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3531    Accepted Submission(s): 1364 Problem Description In a two-dimensional plane there are two line belts, there are two segments AB…
http://acm.split.hdu.edu.cn/showproblem.php?pid=3400 题意: 有两条带子ab和cd,在ab上的速度为p,在cd上的速度为q,在其它地方的速度为r.现在计算从a出发到达d的最少花费时间. 思路: 分别在ab和cd两段线路上找一个转折点,然后就是由这三段路组成. 设ab上的线路长度为x,cd上的为y,其余为z. 那么总的时间就是,分开来考虑,,F(x)是个单调递增函数,G(y,z)是个凹性函数. 那么总的T函数还是一个凹性函数,那么就可以三分了,对…
从A出发到D,必定有从AB某个点E出发,从某个点F进入CD 故有E,F两个不确定的值. 在AB上行走的时间   f = AE / p 在其他区域行走的时间 g = EF / r 在CD上行走的时间   h = FD / q 总时间 T = f + g + h 当E确定时,T1 = g + h + C   此时g时一个先减后增的凹函数,h是一个单调递减的凹函数,根据凹函数的性质,故T1是一个凹函数 反之亦然,故需要三分确定其中一个点的位置,再三分另一个点的位置. #include<stdio.h>…
思路:要求最短时间从A到D,则走的路线一定是AB上的一段,CD上的一段,AB与CD之间的一段. 那么可以先三分得到AB上的一个点,在由这个点三分CD!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #def…
题意:给你两条线段AB,CD:然后给你在AB,CD上的速度P,Q,在其它部分的速度是R,然后求A到D的最短时间. 思路:用三分枚举从AB线段上离开的点,然后再用三分枚举在CD的上的点找到最优点,求距离和时间就可以. #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; ; int t; double p,q,r; stru…
三分. #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-…
Problem Description In a two-dimensional plane there are two line belts, there are two segments AB and CD, lxhgww's speed on AB is P and on CD is Q, he can move with the speed R on other area on the plane. How long must he take to travel from A to D?…