A. Wizards and Trolleybuses

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/167/problem/A

Description

In some country live wizards. They love to ride trolleybuses.

A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a distance of d meters from the depot. We know for the i-th trolleybus that it leaves at the moment of time ti seconds, can go at a speed of no greater than vi meters per second, and accelerate with an acceleration no greater than ameters per second squared. A trolleybus can decelerate as quickly as you want (magic!). It can change its acceleration as fast as you want, as well. Note that the maximum acceleration is the same for all trolleys.

Despite the magic the trolleys are still powered by an electric circuit and cannot overtake each other (the wires are to blame, of course). If a trolleybus catches up with another one, they go together one right after the other until they arrive at the final station. Also, the drivers are driving so as to arrive at the final station as quickly as possible.

You, as head of the trolleybuses' fans' club, are to determine for each trolley the minimum time by which it can reach the final station. At the time of arrival at the destination station the trolleybus does not necessarily have zero speed. When a trolley is leaving the depot, its speed is considered equal to zero. From the point of view of physics, the trolleybuses can be considered as material points, and also we should ignore the impact on the speed of a trolley bus by everything, except for the acceleration and deceleration provided by the engine.

Input

The first input line contains three space-separated integers nad (1 ≤ n ≤ 105, 1 ≤ a, d ≤ 106) — the number of trolleybuses, their maximum acceleration and the distance from the depot to the final station, correspondingly.

Next n lines contain pairs of integers ti vi (0 ≤ t1 < t2... < tn - 1 < tn ≤ 106, 1 ≤ vi ≤ 106) — the time when the i-th trolleybus leaves the depot and its maximum speed, correspondingly. The numbers in the lines are separated by spaces.

Output

For each trolleybus print a single line the time it arrives to the final station. Print the times for the trolleybuses in the order in which the trolleybuses are given in the input. The answer will be accepted if the absolute or relative error doesn't exceed 10 - 4.

Sample Input

3 10 100000 105 111000 1

Sample Output

1000.50000000001000.500000000011000.0500000000

HINT

题意

有n辆车,车的加速度为a,他们都要从起点开到终点,起点终点距离为d

第i辆车的发车时间是t[i],最大速度是v[i]

保证,不能超车

问你每辆车到达终点的时间是多少

题解:

高中物理题,稍微推推公式O1回答就好了

代码:

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int n;
double a,d;
double t[1000005],v[1000005];
double ans[1000005];
int main()
{scanf("%d%lf%lf",&n,&a,&d);for(int i=0;i<n;i++){scanf("%lf%lf",&t[i],&v[i]);if(v[i]*v[i]/(2*a)>=d)ans[i]=sqrt(2.*d/a)+t[i];elseans[i]=v[i]/a + (d-v[i]*v[i]/(2.0*a))/v[i]+t[i];}for(int i=1;i<n;i++){if(ans[i]<ans[i-1])ans[i]=ans[i-1];}for(int i=0;i<n;i++)printf("%.10f\n",ans[i]);
}

Codeforces Round #114 (Div. 1) A. Wizards and Trolleybuses 物理题相关推荐

  1. Codeforces Round #698 (Div. 2)(A ~ F)6题全,超高质量题解)【每日亿题】2021/2/4

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 [每日亿题]Codeforces Round #698 (Div. 2)(A ~ F)6题全,超 ...

  2. Codeforces Round #699 (Div. 2) (A ~ F)6题全,超高质量良心题解【每日亿题】2021/2/6

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) (A.B.C)[每日亿题]2021/2/ ...

  3. Codeforces Round #114 (Div. 2)

    http://codeforces.com/contest/168 A:很水的题,可是个竟然错了一次丢人啊,当时舍友在给女朋友打电话,所以有点分心吵啊...粗心的错误. 先求出总共需要的巫师数量t,然 ...

  4. Codeforces Round #370 (Div. 2) A. Memory and Crow 水题

    A. Memory and Crow 题目连接: http://codeforces.com/contest/712/problem/A Description There are n integer ...

  5. Codeforces Round #311 (Div. 2) A. Ilya and Diplomas 水题

    A. Ilya and Diplomas Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/ ...

  6. Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题

    A. Dasha and Stairs 题目连接: http://codeforces.com/contest/761/problem/A Description On her way to prog ...

  7. Codeforces Round #404 (Div. 2) B. Anton and Classes 水题

    B. Anton and Classes 题目连接: http://codeforces.com/contest/785/problem/B Description Anton likes to pl ...

  8. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题

    A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...

  9. Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题

    A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...

最新文章

  1. Date, TimeZone, MongoDB, java中date的时区问题
  2. opengl教程 linux,绘制基本的几何图形 - OpenGL编程学习实战教程_Linux编程_Linux公社-Linux系统门户网站...
  3. Pixhawk飞控源码目录结构及编译流程分析
  4. 数学建模中常用的方法
  5. android.os文件,使用android.os.memoryfile的文件IO
  6. HTML5锚点请用id代替name
  7. 二维标准正态分布的matlab方程
  8. spark压缩和序列化相关
  9. 人脸检测进阶:更快的5点面部标志检测器
  10. 淘宝用户行为分析——通过excel分析
  11. 双网卡双线路DNS解析分析(转)
  12. linux文件最大访问数,测试Linux最大打开文件数参数
  13. VideoView源码分析
  14. java微信开发之--更换背景图片
  15. 论文笔记:FILLING THE G AP S: MULTIVARIATE TIME SERIES IMPUTATION BY GRAPH NEURAL NETWORKS
  16. [乡土民间故事_徐苟三传奇]第四四回_赵员外苕吃假香肠
  17. 马丁福勒《UML精粹》读书笔记_第八章
  18. (十六)admin-boot项目之文件存储上传与下载minio
  19. 电影-300斯巴达勇士
  20. 敏捷开发实践——Team Captain如何把控项目风险

热门文章

  1. C和汇编---sizeof运算符和strlen函数
  2. BestCoder Round #86 1002 HDU 5805 ——NanoApe Loves Sequence
  3. Linux02进程内存管理
  4. java实现矩阵相乘
  5. 阿里云sql监控配置-druid
  6. 自适应阈值化操作:adaptiveThreshold()函数
  7. 学习vue.js的自我梳理笔记
  8. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---4
  9. mysql 位操作支持
  10. void ,NULL与0的区别联系