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 ...
随机推荐
- 深入浅出Koa
深入浅出Koa(1):生成器和Thunk函数 Koa是个小而美的Node.js web框架,它由Express的原班人马打造的, 致力于以一种现代化开发的方式构建web应用. 通过这个系列,你将能够理 ...
- wpa_supplicant wpa_cli 的使用说明
wpa_supplicant -d -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -iwlan0 -B 会在/data/misc/wifi/下产生 ...
- spring 分散配置
Spring简化了加载资源文件的配置,可以通过<context:property-placeholder去加载,这个元素的写法如下: <context:property-placehold ...
- C++ concepts: Compare
The concept Compare is a set of requirements expected by some of the standard library facilities fro ...
- ligerUI调用$.ligerDialog.open弹出窗口,关闭后无法获取焦点问题
1:调用父窗口某一个文件框,获取焦点, parent.window.document.getElementByIdx_x("roleName").focus(); 2:关闭父窗 ...
- JPA 系列教程6-单向多对多
JPA中的@ManyToMany @ManyToMany注释表示模型类是多对多关系的一端. @JoinTable 描述了多对多关系的数据表关系. name 属性指定中间表名称 joinColumns ...
- shell 空格问题
1.定义变量时, =号的两边不可以留空格. eg: gender=femal------------right gender =femal-----------wrong gender= femal- ...
- Object对象
1.Object类:所有类的根类.是不断抽取而来的,具备所有对象都具有的共性内容.其中的方法,任何对象都可以调用.继承而来的. equals()方法: Object类的equals源码:比较两个对象是 ...
- php如何获取本地手机号
<?php function inquiry_number_infor($phonenumber) /* *传入手机号码,通过API的到xml格式数据,对xml进一步解析,最后返回相应的号码信息 ...
- as3 组件定义
package kingBook{ import flash.display.MovieClip; import flash.events.Event; import flash.utils.setT ...