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 ...
随机推荐
- 分层图最短路【bzoj2662】[BeiJing wc2012]冻结
分层图最短路[bzoj2662][BeiJing wc2012]冻结 Description "我要成为魔法少女!" "那么,以灵魂为代价,你希望得到什么?" ...
- idea dao使用@Mapper注解 业务类使用@Autowired 注入dao 爆红问题
实际项目跑起来无影响,但是看起来不太爽. 可以在dao类添加org.springframework.stereotype.Repository 注解 或者可以在service类中使用 javax.an ...
- 解决Nginx启动失败
一.Nginx下载http://nginx.org/en/download.html 二.Nginx启动失败原因1.本人下载的是nginx-1.12.1(稳定版),下载完解压后,进入路径中,start ...
- 理解js继承的6种方式
想要继承,就必须要提供个父类(继承谁,提供继承的属性) 一.原型链继承 重点:让新实例的原型等于父类的实例. 特点:1.实例可继承的属性有:实例的构造函数的属性,父类构造函数属性,父类原型的属性.(新 ...
- Python 起步 多版本共存配置
上次我选择的是py2.x,如果我要再装一个py3.x呢 我们去设置环境变量,然后去命令行输入python,这里我故意把环境变量放在第一行,貌似换成3.7了 我们把2.7的放在3.7的前面呢?又换回去了 ...
- spring事物的管理方式
Spring事务配置的五种方式 转载大神总结: https://blog.csdn.net/xuanjiewu/article/details/51604967: 自己总结:这里只总结spring编程 ...
- SPA 介绍
SQL 性能分析器(SPA)工具概览 作为 Oracle Real Application Testing 选件/特性,这篇文章将提供一个关于 SQL 性能分析器(SPA)工具的简要概览.这是此系列的 ...
- WebGL之物体选择
原文地址: WebGL之物体选择 使用WebGL将图形绘制到画布后,如何与外部进行交互?这其中最关键的就是如何实现物体的选择.比如鼠标点击后判断是否选中了某个图形或图形的某个部分. 本节实现的效果: ...
- 使用:/usr/bin/phpize 报错
使用:/usr/bin/phpize 出现下面错误提示 Can't find PHP headers in /usr/include/php The php-devel package is requ ...
- [luogu 1660]数位平方和
题目描述 定义S(n)表示n的各个数位的k次方的和.定义$H(n)=min{n,S(n),H(S(n))}$. 求$$\sum _{i=A} ^{B} {H(i)} \mod 10000007$$ 输 ...