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> ...
随机推荐
- select count(*) from user注入
先来看一条sql语句: mysql; +------+----------+----------+------------+ | id | username | password | flag | + ...
- 2017百度春招<不等式排列>
题目: 度度熊最近对全排列特别感兴趣,对于1到n的一个排列,度度熊发现可以在中间根据大小关系插入合适的大于和小于符号(即 '>' 和 '<' )使其成为一个合法的不等式数列.但是现在度度熊 ...
- beego学习笔记(4):开发文档阅读(2)
bee工具的安装和使用 bee 工具是一个为了协助快速开发 beego 项目而创建的项目,通过 bee 您可以很容易的进行 beego 项目的创建.热编译.开发.测试.和部署. go get gith ...
- Linux Shell基础篇——变量
一.Shell中的变量 注:这里所说的Shell是Bash Shell,我姑且统称为Shell. Shell中的变量分为用户自定义变量.环境变量.位置参数变量.预定义变量.在Shell中,变量的默认类 ...
- ubuntu 上 安装多个php版本
Ubuntu上官方的源,比如 Ubuntu14.04 默认源中的是 PHP5.6.x.Ubuntu16.04 默认源中的是 PHP7.0.x,那么如果想在 Ubuntu16.04 上安装 PHP7.1 ...
- ConcurrentMap
ConcurrentMap接口下有两个重要的实现: ConcurrentHashMap ConcurrentSkipListMap(支持并发排序功能,弥补ConcurrentHashMap) Conc ...
- 小程序授权怎么写 , 用户点击取消授权 调用 wx.authorize
点击获取授权 onLoad: function (options) { console.log("onLoad====="); var that=this; wx.getUserI ...
- pdb-不需要IDE也能调试
python中有个pdb模块,使python代码也可以像gdb那样进行调试,一般情况下pdb模块可以在代码内直接使用,也可以通过命令行参数的形式添加该模块进行调试(python -m pdb file ...
- svm 中采用自动搜索参数的方式获得参数值
载时自http://blog.csdn.net/u011177305/article/details/46458801?locationNum=1 OpenCV中SVM类是提供了优化参数值功能的,下面 ...
- spring_150902_hibernatedaosupport
实体类: package com.spring.model; import javax.persistence.Entity; import javax.persistence.Id; import ...