
1998 HIGH
SCHOOL PROGRAMMING CONTEST
Problem 5 – The Grand Prize Game
Description:
The Late Show (airing at 7:09 P.M.) is working on a new game to replace "Stupid Human Tricks." This new game segment is called the Grand Prize Game in which audience members are attempting to throw balls at a series of six cups. If the participant gets the ball in the first cup, he/she then gets to throw a ball at the next cup. For each successful throw the participant receives an additional (and better) prize. For a successful throw into sixth cup the participant receives the Grand Prize.

The cups have a height of the 0.2 m and a radius of 0.2 m. The cups are spaced 0.6 meters apart from each other (measured from the center of the cup to the center of the next cup). The center of the first cup is 0.3 m from the point where the ball is released. We assume the participant throws the ball straight.
The input parameters are the height from which the ball is thrown, six pairs of velocities(m/s) and angles(degrees) for the throws.(Each value will be input on a separate line, therefore there will be 13 total lines of input.) Since the participant will not advance from cup to cup unless he/she hits the previous cup, print out "Hit cup #." if participant made it into the cup until the participant misses. For the missed cup print "Missed cup #." Do not print out the rest of the throws.
The time of flight for a ball thrown at angle q can be found by solving the equation:
vot× sin(q) - ½ gt2 = hc
- hk . hk is the height of ball when it was released. hc is the height of the cup. We know that g (the
acceleration due to gravity) is 9.8 m/s2, so our solutions for t become 0 (a solution we can ignore)
and the time when the ball is at the height of the cup. The distance the ball
will travel is given by the formula
, where t is the
time calculated above.
Example:
Input:
1
1
0
2
45
3
40
4
40
5
40
4.5
70
Output:
Hit cup 1.
Hit cup 2.
Hit cup 3.
Hit cup 4.
Missed cup 5.
Additional
Notes:
· The angle (q) will probably need to be expressed in radians instead of degrees for your language's sin() and cos() functions to work properly. To convert an angle in degrees to radians, use the following formula:
. If your language has a function or a constant defined to
return pi (p), use it, otherwise use the approximation p »
3.14159.
· The distance will be a nonnegative integer less than or equal to 32767, but the approach velocity can be a decimal (floating-point) quantity.
· All inputs will be positive.