Codeforces Round #327 590B Chip 'n Dale Rescue Rangers(等效转换,二分)
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(等效转换,二分)的更多相关文章
- CodeForces 590B Chip 'n Dale Rescue Rangers
这题可以o(1)推出公式,也可以二分答案+验证. #include<iostream> #include<cstring> #include<cmath> #inc ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- codeforces590b//Chip 'n Dale Rescue Rangers//Codeforces Round #327 (Div. 1)
题意:从一点到另一点,前t秒的风向与t秒后风向不同,问到另一点的最短时间 挺难的,做不出来,又参考了别人的代码.先得到终点指向起点的向量,设T秒钟能到.如果T>t则受风1作用t秒,风2作用T-t ...
- 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 ...
- Codeforces Round #327 (Div2) A~E
CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...
- 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 ...
随机推荐
- Ubuntu使用技巧
命令 获取系统安装包的编译源码及脚本 apt-get source package 查询端口被占用的进程 lsof -i:端口号 配置 配置阿里源 # mv /etc/apt/source.list ...
- OpenStack基础知识-tox的详解介绍
1.tox简介 tox是通用的虚拟环境管理和测试命令行工具.tox能够让我们在同一个Host上自定义出多套相互独立且隔离的python环境,每套虚拟环境中可能使用了不同的 Python 拦截器/环境变 ...
- [WIP]laravel 入门
创建: 2019/06/20 安装 composer brew install composer laravel composer global require "laravel/i ...
- PHP现阶段发现的不足点
1.php测试单元的实现(参考文档:https://blog.csdn.net/weixin_41282397/article/details/85052015)
- 洛谷P2798 爆弹虐场
P2798 爆弹虐场 题目描述 某年某月某日,Kiana 结识了一名爆弹虐场的少年. Kiana 仗着自己多学了几年OI,所以还可以勉勉强强给这位少年 讲一些自己擅长的题.具体来说,Kiana 先给这 ...
- IDEA调试方法总结及各种Step的区别
1.打断点 IDEA 添加断点的方式还是比较简单的,我们可以直接在某一行的代码行号后点击鼠标左键进行添加 2.启动调试 如果我们想要调试我们的程序,那我们必须以DEBUG的形式启动我们的程序,以DEB ...
- 【ACM】最少乘法次数 - 树
最少乘法次数 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 给你一个非零整数,让你求这个数的n次方,每次相乘的结果可以在后面使用,求至少需要多少次乘.如24:2*2 ...
- leetcode 91. 解码方法
题目描述: 一条包含字母 A-Z 的消息通过以下方式进行了编码: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 给定一个只包含数字的非空字符串,请计算解码方法的总数 ...
- 使用scrapy+selenium爬取淘宝网
--***2019-3-27测试有效***---- 第一步: 打开cmd,输入scrapy startproject taobao_s新建一个项目. 接着cd 进入我们的项目文件夹内输入scrapy ...
- Windows应用程序未响应
昨天在安装postgresql的扩展功能postgis的时候,stackbuilder刚打开就死掉,一直未响应,刚开始以为是内存的原因,后来发现并没有占用太多内存,最后打开vpn发现就可以了,原来是网 ...