For each $x$, we have
$$\frac{1}{2}at^2+v_0t-x=0,$$
and it is obvious that
$$t=\frac{-v_0+\sqrt{v_0^2+2ax}}{a}.$$
We can easily notice that it can be transformed into
$$t=\sqrt{\frac{v_0^2}{a^2}+\frac{2x}{a}}-\frac{v_0}{a}.$$
To avoid repeated calculation, let
$$\alpha = \frac{v_0^2}{a^2},\;\;\;\beta = -\frac{v_0}{a},\;\;\;\theta = \frac{2}{a},$$
we have
$$t=\sqrt{\alpha+\beta x}+\theta.$$
Now, for each case, we only need two addition, one multiplication, and one square root calculation.
北京记者的速度真的是快的一匹
这个题目出的啊,excited
只有做做水题才能维持得了生活的样子……
For each $x$, we have
$$\frac{1}{2}at^2+v_0t-x=0,$$
and it is obvious that
$$t=\frac{-v_0+\sqrt{v_0^2+2ax}}{a}.$$
We can easily notice that it can be transformed into
$$t=\sqrt{\frac{v_0^2}{a^2}+\frac{2x}{a}}-\frac{v_0}{a}.$$
To avoid repeated calculation, let
$$\alpha = \frac{v_0^2}{a^2},\;\;\;\beta = -\frac{v_0}{a},\;\;\;\theta = \frac{2}{a},$$
we have
$$t=\sqrt{\alpha+\beta x}+\theta.$$
Now, for each case, we only need two addition, one multiplication, and one square root calculation.
Hence is the code: