提示: 欢迎访问OurACM平台。
Problem 1942 Garden

Accept: 14    Submit: 44
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Every giantarum has its garden. So welcome to AekdyCoin’s garden! Here is the spray pond!

The small blue point in the figure above is the headwater. The stream path is red. And there are some kind of dam-board, any of them has magic power! When the water meets with the dam-board, something will happen!

Consider the headwater as one point in three-dimensional space and its coordinate is (0, 0, H). Then a velocity is given as the water’s horizontal velocity. You could see in the figure following:

So if there is no dam-board cut off the stream path, the stream path will just as the yellow path in the figure above!( Air drag, friction will be ignore!)

But if there exist some dam-board cut off the stream path

So, if the dam-board cut off the stream, the Vertical velocity of the stream will become 0! And then depend on the magic power of the dam-board, the New_Vx ,New_Vy of New_V will change!

There are three kind of dam-board in AekdyCoin’s Garden.

(1) Type 0: the horizontal velocity vector rotate anticlockwise for some radian:

(2) Type 1: The Vx will be modified!

If the Vx is modified, we could know the horizontal velocity will be modified too!

(3) Type 2: The Vy will be modified!

If the Vy is modified, we could know the horizontal velocity will be modified too!

Note: The modification happened at the moment when the stream touches the dam-board

Now AekdyCoin focus on a water-drop at the headwater and its mass is exactly M (kg).

Now Stupid AekdyCoin want you to write a program to tell him the time this water-drop need to drop onto the plane (z = 0). (In this problem, the acceleration due to gravity G is 9.18)

Input

In the first line there is an integer T, indicates the number of test cases. (T <= 10) In each case, the first line contains three real numbers Vx,Vy and H, indicates the horizontal velocity and the headwater’s three dimensional coordinate is (0,0,H). (-1000 <= Vx,Vy <= 1000, |H| <= 1000)

Then a single line contains only one integer N, indicates the number of dam-board(0 <= N <= 10)

Then following N lines:

In each line, the first real number h is the height of the dam-board(|h| <= 1000), and then an integer Ni indicates the coordinate of the Ni vertex of the dam-board(3<=Ni<=10). Then Ni coordinate (xi,yi) (-1000<=xi,yi<=1000,xi,yi are both integers)(Dam-board is always on a horizontal plane, so (xi,yi) indicates the three dimensional coordinate of the vertex is (xi,yi,h),and it is convex polygon.All the points will be given in clockwise or anticlockwise order!No two board share the same height!). Then one integer typ indicate the type of the dam-board, at last one real number k:

(1) If the typ = 0, then the k indicate the radian(|k| <= 2.0 * PI,PI = 3.1415…)

(2) If typ = 1 or typ = 2 then we should change Vx or Vy into k! (|k| <= 1000)

Output

Output “Case d: “first where d is the case number counted from one. Then output the time the water-drop need to drop onto the plane (z = 0), then output the answer rounded to 2 digits after the decimal point.Otherwise if the water-drop could not drop onto the plane (z = 0) forever, just output “Forever!”.

Sample Input

2 1 0 -5 0 1 0 18.36 1 9.18 4 0 0 100 0 100 100 0 100 0 3.1415927

Sample Output

Case 1: Forever! Case 2: 4.24

Hint

In case 1:

In case 2:

Source

2010 ACM-ICPC Multi-University Training Contest(1)--Host by FZU

Submit  Back  Status  Discuss