Codeforces Beta Round #5 D. Follow Traffic Rules 物理
D. Follow Traffic Rules
题目连接:
http://www.codeforces.com/contest/5/problem/D
Description
Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the road where they are placed. Right after passing the sign it is allowed to drive at any speed.
It is known that the car of an average Berland citizen has the acceleration (deceleration) speed of a km/h2, and has maximum speed of v km/h. The road has the length of l km, and the speed sign, limiting the speed to w km/h, is placed d km (1 ≤ d < l) away from the capital of Berland. The car has a zero speed at the beginning of the journey. Find the minimum time that an average Berland citizen will need to get from the capital to Bercouver, if he drives at the optimal speed.
The car can enter Bercouver at any speed.
Input
The first line of the input file contains two integer numbers a and v (1 ≤ a, v ≤ 10000). The second line contains three integer numbers l, d and w (2 ≤ l ≤ 10000; 1 ≤ d < l; 1 ≤ w ≤ 10000).
Output
Print the answer with at least five digits after the decimal point.
Sample Input
1 1
2 1 3
Sample Output
2.500000000000
Hint
题意
有一个长度为l的道路,你的加速是a
从[0,d]的限速是w,[d,l]的限速是v,问你最少花费多少时间从起点到终点。
题解:
高中物理题,四种情况,都讨论一下,然后瞎搞搞
代码
#include<bits/stdc++.h>
using namespace std;
double a,v,l,d,w;
int main()
{
cin>>a>>v>>l>>d>>w;
double t = w/a;
w = min(min(w, v), sqrt(2 * a * d));
if (2*a*d+w*w>2*v*v)
t = (d-v*v/a+w*w/a/2)/v+(2*v-w)/a;
else
t = (2*sqrt(a*d+w*w/2)-w)/a;
l = l - d;
double t2 = (v-w)/a;
if(l-w*t2-0.5*a*t2*t2>0)
t2 = t2 + (l-w*t2-0.5*a*t2*t2)/v;
else
t2 = (-w+sqrt(w*w+2.0*a*l))/a;
printf("%.12f\n",t+t2);
}
Codeforces Beta Round #5 D. Follow Traffic Rules 物理的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #62 题解【ABCD】
Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- React Native 与 夜神模拟器的绑定
之前一直用真机去调试, 每回更新一次都需要手动摇晃手机后才能reload JS, OMG,太麻烦了. 后来寻思模拟器网上推荐用Geny...什么的模拟器,但是那个模拟器还需要VBox一起用. 有点麻烦 ...
- nesC编程入门
1.接口 NesC程序主要由各式组件(component)构成,组件和组件之间通过特定的接口(interface)互相沟通.一个接口内声明了提供相关服务的方法(C语言函数).例如数据读取接口(Read ...
- SilverLight 浏览器出现滚动条
照网上说的很多解决方案要不得,最后想了下,直接在body上面加 style="overflow:hidden"解决问题,真觉得微软管理混乱,很多它自己的东西都不支持了.
- Oracle数据库,基础知识
1.Oracle的五大约束条件: 1 主键 primary key2 外键 foreign key,3 唯一 unique,4 检测 check5 非空 not null 实例运用: -- ...
- 4.rabbitmq 路由
1. 生产者 #coding:utf8 import pika import json import sys severity = sys.argv[1] if len(sys.argv) > ...
- HDU 3085 Nightmare Ⅱ(双向BFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3085 题目大意:给你一张n*m地图上,上面有有 ‘. ’:路 ‘X':墙 ’Z':鬼,每秒移动2步,可 ...
- Git分支管理小结
分支管理命令 每次提交,Git都把它们串成一条时间线,这条时间线就是一个分支.截止到目前,只有一条时间线,在Git里,这个分支叫主分支,即master分支.HEAD严格来说不是指向提交,而是指向mas ...
- 删除WP提示:自动升级WordPress失败
wordpress后台总有烦人的升级失败的提示,查了半天找不到怎么去掉:“自动升级WordPress失败--请再试一次”这个提示的方法,特意分享出来 方法/步骤 1 打开wordpress根目录找 ...
- git rebase 过程中遇到冲突该怎么解决?
在执行git rebase 过程中经常遇到问题,此时有点慌,一般如何解决呢? 1.先将本地的冲突手动解决 2.执行下面命令 git add . git rebase --contine //继续re ...
- 禁用Flash P2P上传
Mac OS: sudo bash -c 'echo RTMFPP2PDisable=1 >> /Library/Application\ Support/Macromedia/mms.c ...