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. VS2012打包部署教程

    前言 通常我们只是写一些系统,然后想要运行功能的时候就打开代码点击启动,这样只适用于开发人员或者局部开发人员这样做,软件开发的大多数意义上就是拿出开发的软件让用户放心的去点.用户无需知道代码,无需知道 ...

  2. 小程序组件交互 -- 传入js

    1.父组件(wxml页面)向子组件传递 在子组件中定义需要传入的属性 properties: { count: { type: Number, value: 0, observer:function( ...

  3. Proxy模式(代理[延迟]模式)

    Proxy?? Proxy是"代理人"的意思,它指的是代替别人进行工作的人.代理实际上就是使用委托的机制,在代理的过程中你可以做点其他的事情,然后再来执行被代理对象的代码. 知识储 ...

  4. 导入别的类中的bean

    @Configuration class CommonContext { @Bean public MyBolt myBolt() { return new MyBolt(); } } ... @Co ...

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

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

  6. {ldelim},{rdelim} - smarty 内建函数

    {ldelim}和{rdelim}用来转义模板的分隔符,缺省为{和}.你也可以用{literal}{/literal}来转义文本块(如Javascript或CSS). 例: {* 在模板外将原样打印分 ...

  7. 搭建Node.js Redis开发环境

    创建项目 初始化为node项目 $npm init   安装redis   安装@types/node, @types/redis, typescript   初始化TypeScript   配置ts ...

  8. WPF OnApplyTemplate 不执行 或者执行滞后的疑惑

    OnApplyTemplate 不执行 平时如何开发自定义控件的 在WPF自定义控件开发的过程中遇到了这样一个问题,属性更改事件在OnApplyTemplate之前执行.我在写自定义控件的时候,喜欢通 ...

  9. JavaSE之Java基础(4)

    16.String.StringBuilder和StringBuffer的区别 String类是final的,不可变,StringBuilder和StringBuffer可变: 大部分情况下的执行效率 ...

  10. python全栈测试题(一)

    1.执行Python脚本的两种方式 如果想要永久保存代码,就要用文件的方式 如果想要调试代码,就要用交互式的方式即终端命令下和python环境中 2.Pyhton单行注释和多行注释分别用什么? pyt ...