首页 > ACM题库 > HDU-杭电 > hdu 2603 Wiskey’s Power-数学相关-[解题报告]C++
2014
02-10

hdu 2603 Wiskey’s Power-数学相关-[解题报告]C++

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.

Your task is to calculate the coordinates of vomit.
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

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2603

题意:从高度为3米距离天花板0.5米处抛掷一物体,倾角为a,质量为m,初速度为v。若碰到天花板则以反射定律反射出去。问物体能抛多远。

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 ;
 }

 

解题转自:http://www.cnblogs.com/lzsz1212/p/3300244.html


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