CodeForces 590B Chip 'n Dale Rescue Rangers
这题可以o(1)推出公式,也可以二分答案+验证。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std; double X1,X2,Y1,Y2;
double v,t;
double vx,vy,wx,wy; bool check(double mid)
{
double tmpx,tmpy;
if(mid<=t)
{
tmpx=X1+mid*vx;
tmpy=Y1+mid*vy;
double dis=sqrt((X2-tmpx)*(X2-tmpx)+(Y2-tmpy)*(Y2-tmpy));
if(dis/v>mid) return ;
return ;
}
else
{
tmpx=X1+t*vx;
tmpy=Y1+t*vy; tmpx=tmpx+(mid-t)*wx;
tmpy=tmpy+(mid-t)*wy; double dis=sqrt((X2-tmpx)*(X2-tmpx)+(Y2-tmpy)*(Y2-tmpy));
if(dis/v>mid) return ;
return ;
}
} int main()
{
scanf("%lf%lf%lf%lf",&X1,&Y1,&X2,&Y2);
scanf("%lf%lf",&v,&t);
scanf("%lf%lf%lf%lf",&vx,&vy,&wx,&wy); double l=,r=;
double ans;
int t=; while(t--)
{
double mid=(l+r)/2.0; if(check(mid))
{
ans=mid;
r=mid;
}
else l=mid;
}
printf("%.18lf\n",ans);
return ;
}
CodeForces 590B Chip 'n Dale Rescue Rangers的更多相关文章
- Codeforces Round #327 590B Chip 'n Dale Rescue Rangers(等效转换,二分)
t和可到达具有单调性,二分就不多说了.下面说下O(1)的做法,实际上是等效转换,因为答案一定存在,如果在t0之前,那么分解一下 直接按照只有v计算就可以了.反过来如果计算的结果大于t0,那么表示答案在 ...
- 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 ...
- 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 ...
- 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 ...
- (Gym 100685G) Gadget Hackwrench(LCA在线ST)
Gadget Hackwrench time limit per test 2 seconds memory limit per test 64 megabytes input standard in ...
- Codeforces Round #327 (Div2) A~E
CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...
- FC红白机游戏列表(维基百科)
1055个fc游戏列表 日文名 中文译名 英文版名 发行日期 发行商 ドンキーコング 大金刚 Donkey Kong 1983年7月15日 任天堂 ドンキーコングJR. 大金刚Jr. Donkey K ...
随机推荐
- mvc页面中,显示自定义时间格式
1.在model中,遇到datetime格式的字段,用string来表示 model中 /// <summary> /// 开始时间 /// </summary> [Displ ...
- PHP文件相关函数试题
一.问答题 1.返回路径中的文件名部分的函数是什么? 2.改变文件模式的函数是什么? 3.拷贝文件的函数是什么? 4.返回路径中的目录部分的函数是什么? 5.将上传的文件移动到指定位置的函数是? 6. ...
- 1*Json对象声明简单,复合,对象数组
//简单JSON对象 function btn1_click() { var json = { "id": 1001, "name": "张三&quo ...
- Array.length vs Array.prototype.length
I found that both the Array Object and Array.prototype have the length property. I am confused on us ...
- selenium2(WebDriver) API
selenium2(WebDriver) API 作者:Glen.He出处:http://www.cnblogs.com/puresoul/ 1.1 下载selenium2.0的包 官方downl ...
- js里父页面与子页面的相互调用
一.在页面里用 open 打开的子页面: 1.子页面调用父页面的方法,包括子页面给父页面传值: window.opener.methodName(); window.opener.methodName ...
- Python数据分析Python库介绍(1)
一直想写点Python的笔记了,今天就闲着无聊随便抄点,(*^__^*) 嘻嘻…… ---------------------------------------------------------- ...
- Properties集合
Map |--Hashtable |--Properties Properties集合特点: 1.该集合中的键和值都是字符串类型 2.集合中的数据可以保存在IO流中或者从IO流中获取数据. 通常该集合 ...
- js框架——angular.js(3)
1. 过滤filter 过滤就是将内容进行筛选或者转换或者两者都有,一般的表示方式就是在变量后面添加"|",然后加上过滤条件,如—— {{name|currency}} 这个cur ...
- startActivityForResult与onActivityResult
androidActivity之间的跳转不只是有startActivity(Intent i)的,startActivityForResult(Intent intent, int requestCo ...