69 - ZOJ Monthly, August 2008 - 1002
Collision ball game is one of my favorite game when I was young. I was so fond of this game that I nearly decided to be a physical scientist (But I am not now). Firstly I wanted to construct a problem to describe the whole process of this game. But it is too difficult for me and I hate being bsed by others for wrong data.
So I decide to make it easier, but maybe I will construct one next time.
Assume the game is in a triangle with the lower-right angle k (in degree) and height h. (see the picture)
The ball's initial place is in (0, a) and it eventually arrives at (b, 0) with collising the bevel edge only once. The two points (0, a) and (b, 0) will always be on the edge of the triangle.
You are to calculate the distance the ball pass. The process of collision obey the physical law. The angle of incidence equals to the angle of reflection.
The input contains multiple test cases. Each test cases contain four number (all double). The first line is the angle of the triangle k (in degree, 0 < k < 90). The second line is the height h (h > 0). The third line is a. The fourth line is b (a, b >= 0).
Process to the end-of-file.
For each test case print a single line that contains the distance the ball pass (rounded to 2 decimal places).
45 2 1 1 30 2 1 2.3094
Author: LIN, Jiaqiang