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. [转]centos7.2 下 nginx 开机启动

    1.在系统服务目录里创建nginx.service文件 vi /lib/systemd/system/nginx.service 内容如下 [Unit] Description=nginx After ...

  2. java实例练习——基于TCP/IP协议的多客户端通信

    先说一下大概的思路: 应用多线程来实现服务器与多客户端之间的通信 1.服务器端创建ServerSocket,循环调用accept()等待客户端连接: 2.客户端创建一个Socket并请求与服务器端连接 ...

  3. bzoj 3944: Sum(杜教筛)

    3944: Sum Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 4930  Solved: 1313[Submit][Status][Discuss ...

  4. bzoj3876: [Ahoi2014&Jsoi2014]支线剧情(上下界费用流)

    传送门 一道题让我又要学可行流又要学zkw费用流…… 考虑一下,原题可以转化为一个有向图,每次走一条路径,把每一条边都至少覆盖一次,求最小代价 因为一条边每走过一次,就要付出一次代价 那不就是费用流了 ...

  5. Linux之数据库

    crm 1.一定得会用linux发行版 centos 熟悉各种linux命令 2.你的确保linux服务器可以上网 , 一定得有ip地址,且确保dns解析正常 /etc/resolv.conf 3.上 ...

  6. angular中使用canvas画布做验证码

    //填充画布,五位随机数 drawNumber(): void { this.clearCanvas(); let ctx: CanvasRenderingContext2D = this.myGra ...

  7. 转 GTID复制的搭建和问题处理

    ########sample 1: 了解mysqldump 和 mysqlbackup  和 gtid_executed 和 gtid_purged https://www.linuxidc.com/ ...

  8. Murano PL

    To develop applications, murano project refers to Murano Programming Language (MuranoPL). It is repr ...

  9. 双层列表 datagrid里属性

    frozenColumns: [ [{ title: "姓名"}] ], columns: [ [{"title":"延时原因"}], [{ ...

  10. redis安装及简单命令

    Redis 安装 Window 下安装 下载地址:https://github.com/MSOpenTech/redis/releases. Redis 支持 32 位和 64 位.这个需要根据你系统 ...