t和可到达具有单调性,二分就不多说了。下面说下O(1)的做法,实际上是等效转换,因为答案一定存在,如果在t0之前,那么分解一下

直接按照只有v计算就可以了。反过来如果计算的结果大于t0,那么表示答案在t0之后。因为速度分量是可以独立累加的,因此

可以找到一开始就只有w的等效的点。

#include<bits/stdc++.h>
using namespace std; double x[], y[];
double vm, t0;
double v[], w[]; const double eps = 1e-;
double dex, dey, D;
bool unitization(double &dx = dex, double &dy = dey)
{
D = hypot(dx, dy);
if(D > eps){
dx /= D; dy /= D;
return true;
}
return false;
} inline double Dot(double vx, double vy)
{
return dex*vx + dey*vy;
} inline double Cross(double vx, double vy)
{
return dex*vy - dey*vx;
} inline double MinTime(double x0, double y0, double vx, double vy, double x1 = x[], double y1 = y[])
{
dex = x1-x0; dey = y1-y0;
if(!unitization()) return ;
double vh = Cross(vx,vy);
double vn = Dot(vx,vy);
double vc = vn + sqrt(vm*vm - vh*vh);
return D/vc;
} //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
scanf("%lf%lf%lf%lf", x, y, x+, y+);
scanf("%lf%lf", &vm, &t0);
scanf("%lf%lf%lf%lf", v, v+, w, w+);
double t = MinTime(x[], y[], v[], v[]);
if(t0 >= t){
printf("%.18lf\n",t);
}else {
printf("%.18lf\n", MinTime(x[]+(v[]-w[])*t0, y[]+(v[]-w[])*t0, w[], w[]));
}
return ;
}

Codeforces Round #327 590B Chip 'n Dale Rescue Rangers(等效转换,二分)的更多相关文章

  1. CodeForces 590B Chip 'n Dale Rescue Rangers

    这题可以o(1)推出公式,也可以二分答案+验证. #include<iostream> #include<cstring> #include<cmath> #inc ...

  2. Codeforces Round #327 (Div. 2) D. Chip 'n Dale Rescue Rangers 二分 物理

    D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...

  3. Codeforces Round #327 (Div. 1) B. Chip 'n Dale Rescue Rangers 二分

    题目链接: 题目 B. Chip 'n Dale Rescue Rangers time limit per test:1 second memory limit per test:256 megab ...

  4. codeforces 590B B. Chip 'n Dale Rescue Rangers(二分+计算几何)

    题目链接: B. Chip 'n Dale Rescue Rangers time limit per test 1 second memory limit per test 256 megabyte ...

  5. cf590B Chip 'n Dale Rescue Rangers

    B. Chip 'n Dale Rescue Rangers time limit per test 1 second memory limit per test 256 megabytes inpu ...

  6. codeforces590b//Chip 'n Dale Rescue Rangers//Codeforces Round #327 (Div. 1)

    题意:从一点到另一点,前t秒的风向与t秒后风向不同,问到另一点的最短时间 挺难的,做不出来,又参考了别人的代码.先得到终点指向起点的向量,设T秒钟能到.如果T>t则受风1作用t秒,风2作用T-t ...

  7. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  8. Codeforces Round #327 (Div2) A~E

    CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...

  9. Codeforces Round #327 (Div. 2) E. Three States BFS

    E. Three States Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/probl ...

随机推荐

  1. Error mounting / dev / sdb1 in Ubuntu

    Uncommon users of Ubuntu OS, when connecting USB with NTFS file system, can observe the error: " ...

  2. vue -- 插件的开发与使用

    开发插件 插件通常会为 Vue 添加全局功能.插件的范围没有限制--一般有下面几种: 1.添加全局方法或者属性,如: vue-custom-element. 2.添加全局资源:指令/过滤器/过渡等,如 ...

  3. css 实现三级联动菜单

    昨天因为项目中想要把二级联动菜单改成三级联动菜单,所以我就单独写了一个tab导航栏,用纯css的方式实现的三级联动.一开始我想着可以用js实现,但是js的hover事件和mouseenter,mous ...

  4. 自制Java虚拟机(四)-对象、new、invokespecial

    自制Java虚拟机(四)-对象.new.invokespecial 一.对象的表示 刚开始学Java的时候,图书馆各种教程,书名往往都是“Java面向对象高级编程”,通常作者都会与C++做个比较,列出 ...

  5. Python中使用Type hinting 和 annotations

    Type hints最大的好处就是易于代码维护.当新成员加入,想要贡献代码时,能减少很多时间. 也方便我们在调用汉书时提供了错误的类型传递导致运行时错误的检测. 第一个类型注解示例 我们使用一个简单例 ...

  6. 兼容IE的login表单巧妙写法

    利用label来写: HTML: <div class="loginwrap"> <label for="phonenumber" class ...

  7. string类型的方法

    var str1 = ' this is string1 '; var str2 = 'this is string2'; str1.indexOf('s'); //args:string retur ...

  8. The bytes/str dichotomy in Python 3 [transport]

    reference and transporting from: http://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-p ...

  9. SpringMVC05 return (Json)

    这里要主要的是js文件要引入,文中不做解释 1.导入包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xs ...

  10. Spring整合Struts2 注解版

    1.jar包 <!--spring配置--> <dependency> <groupId>org.springframework</groupId> & ...