D. Follow Traffic Rules
来源:互联网 发布:算法博弈论中文版 pdf 编辑:程序博客网 时间:2024/05/16 19:16
题意:
有一条公路,长度为l,在距离d处的地方有一个检查速度的装置,这个装置要求通过这一点时的速度不能高于限定的速度w,有一辆车的最大行驶速度是v,加速度是a(加减的加速度一样),问这个车从公路的起点出发,不违章的情况下,最少需要多长时间
题解:
可以说是物理题+数学题,难点在于要把所有的过程考虑清楚,每一步怎么处理,细节太多,本来思路是清晰的,一见到wa,可能一慌就混乱了,一定要注意心态,虽然一上午只做了一道题,但是感觉这样也许对自己的心性也是一种锻炼吧
/*http://blog.csdn.net/liuke19950717*/#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;double slove(double a,double b,double c)//一元二次方程的正解{ return (-b+sqrt(b*b-4*a*c))/(2*a);}int main(){ double a,v,len,d,w,ans=0; scanf("%lf%lf%lf%lf%lf",&a,&v,&len,&d,&w); if(w>=v||w*w/(2*a)>d)//不会超速,可以一直加速跑 { double x=(v*v)/(2*a);//加满速需要的距离 if(x>=len)//一直加速下去 { ans+=sqrt(2*a*len)/a;//加速时间 } else { ans+=(len-x)/v+v/a; } } else//有超速的可能 { len-=d;//单独讨论限速段 double tx=w*w/(2*a);//加速到限定速度需要的距离 double t=w/a;//加速到限定速度的时间 d-=tx;//限速段其余的路程 ans+=t;d/=2; tx=(v*v-w*w)/(2*a); if(tx>d)//没有加速到最高速 { double tv=sqrt(2*a*d+w*w); ans+=2*(tv-w)/a; } else { ans+=2*(v-w)/a+2*(d-tx)/v;//加速到满后匀速 } //过了限速段后 tx=(v*v-w*w)/(2*a); if(tx>len)//没有加速到最高速 { double tv=sqrt(2*a*len+w*w); ans+=(tv-w)/a; } else { ans+=(v-w)/a+(len-tx)/v;//加速到满后匀速 } } printf("%.12lf\n",ans); return 0;}
0 0
- D. Follow Traffic Rules
- codeforces 5D Follow Traffic Rules
- Codeforces 5D Follow Traffic Rules 水题
- Codeforces 5D. Follow Traffic Rules
- Codeforces Beta Round #5 D. Follow Traffic Rules
- Codeforces Beta Round #5——D. Follow Traffic Rules
- Japanese obey traffic rules strictly
- Consistency model(The system supports a given model if operations on memory follow specific rules)
- Rules
- Rules
- Rules
- Rules
- codeforces 498 d Traffic Jams in the Land
- CodeForces 498D Traffic Jams in the Land
- Codeforces Round #116 (Div. 2, ACM-ICPC Rules) D - Name
- Codeforces #284 div1 D. Traffic Jams in the Land 数论 线段树
- CodeForces 498 D.Traffic Jams in the Land(线段树)
- follow me
- linux - python shell auto completion
- 欢迎使用CSDN-markdown编辑器
- 获取struct 中的member variable 的offset的宏定义
- 商业智能FineBI搭建“智慧医疗”平台
- Service与Activity的关系
- D. Follow Traffic Rules
- android之snackbar的使用
- Elasticsearch 2.3.2 安装部署
- Java并发编程:Callable、Future和FutureTask
- Mac图片反色
- 浅谈Android自定义View
- @echo off
- Linux下部署多个工程的方法
- 控制台里数组,字典输出中文(Extension)