## 题目描述

Problem B – Subway

Subway trains are meant to move people as quickly, safely, and comfortably as possible from station to station. Although the train drivers' unions may not agree, computer operated trains accomplish these goals more effectively than human operated trains. You are to determine the optimal control strategy to move the train from one station to another within the constraints imposed by safety and comfort considerations, as well as the physical limitations of the train itself.

The parameters to the problem are all positive integers not greater than 1000.

d – the distance between stations, in metres

m – the maximum allowable speed of the train, in metres/sec

a – the maximum absolute acceleration of the train, in metres/sec2

j – the maximum absolute jerk, in metres/sec3

The train must be completely stopped at each station and must move in one direction at speeds not exceeding m. Acceleration can be positive (forward) or negative (backwards) but its absolute value must not exceed a. The last parameter, jerk, is the rate of change of acceleration in either direction. That is, acceleration cannot increase or decrease at greater than this rate. This parameter prevents toppling the standing passengers.

There are several test cases. For each test case, standard input has a single line with d, m, a, j. For each test case, standard output should contain a single line giving the minimum time in seconds, to the nearest 0.1 second, required to move between the stations.

## 输入

暂无

## 输出

暂无

## 样例输入

```
1000 70 20 1
```

## 样例输出

```
31.7
```

## 参考代码

```
#include <stdio.h>
#include <math.h>
double D,M,A,J,jtime, jtimeaccellimit, jtimespeedlimit, jtimedistlimit,
atime, dist, delta, a, b, c, r;
double cubrt(double x)
{
return (exp(log(x)/3));
}
main()
{
while (4 == scanf("%lf%lf%lf%lf",&D,&M,&A,&J))
{
jtimeaccellimit = A/J;
jtimespeedlimit = sqrt(M/J);
jtimedistlimit = cubrt(D/2/J);
jtime = jtimeaccellimit;
if (jtimespeedlimit < jtime) jtime = jtimespeedlimit;
if (jtimedistlimit < jtime) jtime = jtimedistlimit;
atime = (M - J*pow(jtime,2))/A;
a = 0.5*A;
b = A*jtime + 0.5*J*pow(jtime,2);
c = J * pow(jtime,3) - D/2;
r = (-b + sqrt(b*b - 4*a*c))/2/a;
if (r < atime) atime = r;
dist = J * pow(jtime,3)
+ 0.5*J*pow(jtime,2)*atime + 0.5*A * pow(atime,2)
+ A * atime*jtime;
printf("%0.1lfn",4*jtime+2*atime+2*(D/2-dist)/M);
}
}
```

## 解析

暂无