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 ...
随机推荐
- mysql 排序后获得某行的位置
假设有test表,下图为表机构和数据,score表示积分.现在要查询积分排名为第几的id?? 查询语句 select id,score,(@rowno:=@rowno+1) as rowno from ...
- VS2005--设置Release模式下调试
今天初略看了下,所谓Release和Debug只是大家和编译器约定的一些生成规则而已,所以调试是无所谓Release和Debug的,只是由于生成的规则不同,可能Release的一些调试结果没Debug ...
- makesfx.exe (Make SFX (Self-extracting archive))
来源: http://www.cr173.com/soft/5500.html http://74.cz/en/make-sfx/ 官方,最新 Make SFX 是一套Win32平台下能让您制作自解压 ...
- centos7 python
yum -y install gcc cd /usr/local/src wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0a1 ...
- 自己开发的轻量级gif动画录制工具
虽然网上已经有LICEcap.GifCam等gif录制工具,但我仍然觉得对于我个人使用还是不够方面,所以自己又写了一个,功能相对简洁一些. Gif Recorder 支持全屏录制和区域录制,可自 ...
- 扩展方法之ToDictionary()
Person类: public class Person { public int Id { set; get; } public string WorkNo { set; get; } public ...
- 旋转图css3
<!doctype html><html> <head> <meta charset="UTF-8"> <title> ...
- @property(nonatomic) UIViewAutoresizing autoresizingMask;
在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高. 1 2 3 4 5 6 7 8 9 enum ...
- DZY Loves Partition
问题描述 DZY喜欢拆分数字.他想知道能否把nn拆成恰好kk个不重复的正整数之和. 思考了一会儿之后他发现这个题太简单,于是他想要最大化这kk个正整数的乘积.你能帮帮他吗? 由于答案可能很大,请模10 ...
- 动画——animation(2)
日常中,我们使用的动画来源有两个方面—— 第一个,自己去定义. 通过@keyframes去定义即可,格式如下: @keyframe animatename{ 0%{ //这里面写初始的对象的css样式 ...