CodeForce 168 C——Wizards and Trolleybuses
来源:互联网 发布:天干地支日期互算法 编辑:程序博客网 时间:2024/04/30 18:58
题意:给定n个火车,加速度,和铁轨长度,然后是每个火车的最大速度和开始出发的时间,问每辆火车到达终点的时刻。
思路:暴力。考虑路上的状态可能不太容易思考,那就直接考虑起点和终点,对于一辆车到达的时间不超过前一辆车。即max(原本时间,前一辆的时间)。注意加速不到最大速度就到终点的情况。
code:
#include <bits/stdc++.h>using namespace std;const int N=1e5+5;int n;double a,d;double p[N],t[N],v[N],s[N];int main(){ scanf("%d%lf%lf",&n,&a,&d); for (int i=0;i<n;i++) scanf("%lf%lf",&t[i],&v[i]),p[i]=t[i]+v[i]/a; //printf("%.6f\n",v[0]/a+d-0.5*a*v[0]/a*v[0]/a); s[0]=t[0]+v[0]/a+(d-0.5*a*v[0]/a*v[0]/a)/v[0]; if (0.5*a*v[0]/a*v[0]/a>d) s[0]=min(s[0],t[0]+sqrt((d*2)/a)); for (int i=1;i<n;i++) { s[i]=t[i]+v[i]/a+(d-0.5*a*v[i]/a*v[i]/a)/v[i]; if (0.5*a*v[i]/a*v[i]/a>d) s[i]=min(s[i],t[i]+sqrt((d*2)/a)); s[i]=max(s[i],s[i-1]); } for (int i=0;i<n;i++) printf("%.6f\n",s[i]);}
0 0
- CodeForce 168 C——Wizards and Trolleybuses
- 博弈——Wizards and Numbers
- Codeforces 168D Wizards and Huge Prize
- codeforces 167C Wizards and Numbers(找规律,博弈)
- codeforce C - Vasya and Robot
- A. Wizards and Demonstration
- CodeForce 180 C ——Letter
- Codeforce 313C Ilya and Matrix
- CodeForce 204 Div2. C Jeff And Rounding
- codeforce 205C - Little Elephant and Interval
- codeforce C. Valera and Elections (DFS)
- codeforce #501 c Misha and Forest
- Codeforce 515 C . Drazil and Factorial 规律
- codeforce 492C. Vanya and Exams
- codeforce 559 C Gerald and Giant Chess
- Codeforce 467C. George and Job(DP)
- codeforce 621C Wet Shark and Flowers
- CodeForce-734C Anton and Making Potions
- JS中Window,document,form的属性,方法,事件(转)
- 什么是多线程,锁,死锁,怎么避免死锁
- 跳槽半年的一些想法
- 算法
- 记一种简单的滑动监听方法
- CodeForce 168 C——Wizards and Trolleybuses
- 湖大ACM—Lowest Bit
- 【bzoj 2821】 作诗 分块
- 2016.3.17HTML入门了解
- 网页报错代码
- linux查找日志技巧
- Android volley 使用OkHttp3.0
- 全栈之路
- TCP与UDP的区别及其报头结构