URI Online Judge | 1163

Angry Ducks

by Marcelo Luiz Onhate Brazil

Timelimit: 1

In a far away land there are two cities, Nlogony, home of the Nlogonies, and Ducklogony, home of their neighbors, the Ducknese. These two cities have been at war for some time and now, in a try to win the war, the Ducknese intend to attack Nlogony with a slingshot that fires ducks. However, to avoid mistakes, they asked you to build a program that, given the values of the slingshot's height (h), the points where the Nlogony city begins (p1) and ends (p2), the shooting angle (α) and the launching speed, calculates if the projectile will hit the target.

For the calculations, assume that the gravity's acceleration is g=9,80665 and that π = 3,14159.


There are various test cases, where each one starts with 1 floating point value h( 1 ≤ h ≤ 150) indicating the slingshot's height, containing, in the next line, 2 integer values p1 and p2( 1 ≤ p1, p2 ≤ 9999) indicating where Nlogony begins and ends, the next line containing 1 integer n(1 ≤ n ≤ 100) indicating the number of tries that will be made to hit the Nlogony and the n following lines containing 2 floating point values indicating the values of the launching's angle α(1 ≤ α ≤ 180) and speed V(1 ≤ V ≤ 150).

The end of the input file is determined by EOF.


For each shoot, your program must print a single line in the following format: “X -> DUCK” for when the duck hits Nlogony or “X -> NUCK” where the duck doesn't hit Nlogony, where X is the maximum distance that the projectile reached until reaching the ground (y = 0). X must be printed with an accuracy of 5 decimal places.

Input Sample Output Sample

368 380
42.3 60
30 55
44 60.876842

367.76208 -> NUCK
270.72675 -> NUCK
379.83781 -> DUCK