2014
02-10

# Wiskey’s Power

Come back school from the 33rdACM / ICPC Asia ChenDu, everyone is exhausted, in particular the captain Wiskey. As saying that night, Wiskey drink a lot of wine, just as he blurred, fall to sleep. All of a sudden, Wiskey felt a slight discomfort in the chest, and then vomiting, vomitted all over. The next day, Wiskey is extremely sluggish, vomit still on the train.

We assume that the quality of vomit is m, and its size can be ignored.
As the figure below:

The vomit start from the blue point A, whose speed is V, and its angle with X-axis is a. If the vomit hit the ceiling, then its value of the speed don’t changed and if before the collision the angle of the speed with X-axis is b, then after the collision the angle of the speed with X-axis is b , too.
Ignore air resistance, acceleration due to gravity g = 9.87m/s2, calculate and output Q.
(you can assume that the vomit will not fall to the higher berth)

Each line will contain three numbers V , m and a (0 <= a < 90)described above.
Process to end of file.

Each line will contain three numbers V , m and a (0 <= a < 90)described above.
Process to end of file.

100 100 45

3.992

mark：推公式解的物理数学题。只要还记得S = vt + 0.5gt^2的自由落体公式，根据其求出总飞行时间，剩下的都很好解决。注意解方程的时候考虑若有2个解，取哪一个。

# include <stdio.h>
# include <math.h>

double pi = acos(-1.0), g = 9.87 ;

int main ()
{
double v, m, a, vx, t, t1, t2 ;
while (~scanf ("%lf%lf%lf", &v, &m, &a))
{
a = a/180*pi ;
vx = v*cos(a), v = v*sin(a) ;
if (v <= sqrt(g)) //will not touch the ceiling
t = (v+sqrt(v*v+6*g))/g ;
else
{
t1 = 2*(v-sqrt(v*v-g))/g ;
t2 = (sqrt(v*v+6*g)-v) / g ;
t = t1 + t2 ;
}
printf ("%.3lf\n", vx * t) ;
}
return 0 ;
}

1. 有限自动机在ACM中是必须掌握的算法，实际上在面试当中几乎不可能让你单独的去实现这个算法，如果有题目要用到有限自动机来降低时间复杂度，那么这种面试题应该属于很难的级别了。