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 ...
随机推荐
- Qt使用中碰到的问题
1.发现table第一列在切换后变黑,或多了行数. 一般是编译出来的.exe文件所使用的qt的dll不匹配造成的.一定要使用编译时,所使用的那个版本的qt的dll.
- Explain of Interaction Operators in UML?
来源于:EA 中的 Interaction Operators Enterprise Architect User Guide Operator Action alt Divide up intera ...
- icon在页面中的使用
https://icomoon.io/app/#/select 1.上传.svg新图标 2.选中那个小图标,点底部导航的生成字体. 3.然后命名,下载. 4.下载下来的内容只有这两处是必须要用的. 5 ...
- C# tostring()汇总
原文:http://www.cnblogs.com/xiaopin/archive/2010/11/05/1870103.html C 货币 2.5.ToString("C") ¥ ...
- opencv----彩色图像对比度增强
图像对比度增强的方法可以分成两类:一类是直接对比度增强方法;另一类是间接对比度增强方法. 直方图拉伸和直方图均衡化是两种最常见的间接对比度增强方法. 直方图拉伸是通过对比度拉伸对直方图进行调整,从而“ ...
- selenium RC
http://blog.sina.com.cn/s/blog_68cb48770100v9c7.html http://www.cnblogs.com/hyddd/archive/2009/05/24 ...
- Ubuntu下安装使用MongoDB
安装 官网下载: https://www.mongodb.org/ 解压解包 重命名为mongodb 移动到/usr/local/目录下 创建连个软连接 ln -s /usr/local/mongo ...
- 多校 Cow Bowling
题目链接:http://acm.hust.edu.cn/vjudge/contest/124435#problem/I 密码:acm Sample Input Sample Output 分析: #i ...
- ubuntu虚拟机和主机互ping及secureCRT使用
1.首先使用ifconfig查看IP,如果没有IP的话就配置IP,配置的IP要和主机在一个网段,可以使用ipconfig查看主机(WIN7)的ip地址. 2.根据ifconfig列出的网卡配置IP地址 ...
- Compress a folder using powershell
There are many ways to compress a folder using powershell: Method 1: Using System.IO.Compression and ...