HDU 2603 Wiskey's Power(物理题)

Wiskey's Power

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 662    Accepted Submission(s): 309

Problem Description
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.
HDU 2603 Wiskey's Power(物理题)_第1张图片

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:
HDU 2603 Wiskey's Power(物理题)_第2张图片

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)
 
Input
Each line will contain three numbers V , m and a (0 <= a < 90)described above.
Process to end of file.
Output
For each case, output Q in one line, accurate up to 3 decimal places.
Sample Input
 
   
100 100 45
Sample Output
 
   
3.992
Author
WhereIsHeroFrom
Source
HDU 1st “Vegetable-Birds Cup” Programming Open Contest
Recommend
lcy   |   We have carefully selected several similar problems for you:  2600 2604 2606 2605 2602 

题解:一个喝醉的人,在3m高的地方呕吐。。。(我都想吐。。。)他是斜向上吐的,可能会吐到天花板。。。
          问你这个人吐了多远的水平距离。
          物理题啊。套公式即可。
          这是Wiskey's Power ????(我又想笑。。。)

AC代码:
#include
#include
#include
#define PI acos(-1.0)
#define g  9.87

int main()
{
	double v,m,a;
	double H2=0.5; int H1=3;
	while(~scanf("%lf%lf%lf",&v,&m,&a))
	{
		double Vx=v*cos(a*PI/180); //水平速度 
		double Vy=v*sin(a*PI/180);  //垂直速度 
		double x,t1,t2,t;
		if(Vy*Vy/(2*g)>H2)		//吐得超过天花板。。。。 
		{   
	        double t1=2*(Vy-sqrt(Vy*Vy-2*H2*g))/g; //吐上天花板时:上升和下落 
            double t2=(sqrt(Vy*Vy+2*g*H1)-Vy)/g; // 下落 
            t=t1+t2;  
		}
		else   //吐不到天花板 
        {
            t=2*Vy/g+(sqrt(Vy*Vy+2*g*H1)-Vy)/g;
        }
        x=t*Vx; 
		printf("%.3lf\n",x);
	}
	return 0;
}



你可能感兴趣的:(HDUOJ,ACM_物理/化学/数学公式)