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> ...
随机推荐
- python3.4.3安装allure2记录
一.安装:cmd执行命令pip install allure-pytest 二.下载allure2:2.7.0版本 https://dl.bintray.com/qameta/generic/io/q ...
- javaScript-继承2种方式
1.组合继承 组合继承带来的问题很明细就是父类的构造函数会调用两次,如: function Person(name, age, sex) { this.name = name; this.age = ...
- nginx报502修复日志
参考:https://www.baidu.com/link?url=PGd7mgvalnQp0MOVZTyDJIvr6_eJn1hmPlmsLpdj2vH6w3FzMt3pZEd_MKpoiqX1OF ...
- 转:mysql日志(Windows下开启Mysql慢查询、通用日志)
一.Windows下开启Mysql慢查询详解 //show variables like '%quer%';查询是否开启了慢查询!! 第一步:修改my.ini(mysql配置文件) 在my.ini中 ...
- 保存进程的pid 文件目录/var/run/
http://blog.ddup.us/?p=110 http://blog.csdn.net/fyinsonw/article/details/4113124 首先声明这不是愚人节消息,事实上这个消 ...
- MySQL之查漏补缺
1.TRUNCATE语句和DELETE语句的区别 1.delete语句,是DML语句,truncate语句通常被认为是DDL语句. 2.delete语句,后面可以跟where子句,通常指定where子 ...
- 秀尔算法:破解RSA加密的“不灭神话” --zz
http://netsecurity.51cto.com/art/201508/488766.htm RSA加密曾被视为最可靠的加密算法,直到秀尔算法出现,打破了RSA的不灭神话. RSA加密 VS ...
- (转)HttpClient 模拟登陆,保持会话并进行后续操作
转自:http://unmi.cc/httpclient-login-session android实现session保持 SessionID的本质
- 第 18 章 Django 入门
当今的网站实际上都是富应用程序(rich application),就像成熟的桌面应用程序一样.Python提供了一组开发Web应用程序的卓越工具.在本章中,我们将学习如何使用Django(http: ...
- sed实践
后来也找到一篇文章讲的很详细: http://www.cnblogs.com/ctaixw/p/5860221.html --------------------------------------- ...