Last Christmas, Patty was very busy embroidering a beautiful hand-made painting for Tony. When she finished, she placed a tiny hook behind the frame so that Tony could hang it on the wall.
Tony is very bad at decorating his house, but he really likes his gift so he wants it to be placed in the best place of the house. He plans to nail two nails on the wall with a rope tied to them, and he wants to have a preview of where the painting will be placed at the end, before he ruins his wall with the holes of misplaced nails.
He has drawn a Cartesian plane on the wall and has chosen two points: ( − 3 , 8 ) and ( 5 , 2 ) , where he pretends to nail each nail, and he plans to use a rope of length 1 5 . Now, he doesn’t know where the tiny hook of his gift will be located.
Please help Tony to visualize his new decoration, calculating where that hook will be. Assume that the painting is heavy enough to keep the rope tense, and the knots to tie it to the nails don’t diminishes the length. Tony’s world is very boring, so friction does not exist.
If the coordinates of the hook are ( x 0 , y 0 ) , report your answer as ⌊ 1 0 3 ( x 0 + y 0 ) ⌋ .
Source: Programming Contest X - Gran Premio ACM México CA 2017 - Fecha 3
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let F 1 = ( − 3 , 8 ) and F 2 = ( 5 , 2 ) . If we trace all the points where the hook can be keeping tense the rope, we get an ellipse with foci F 1 and F 2 , and center C = 2 1 ( F 1 + F 2 ) = ( 1 , 5 ) , and we just want its lowest point. We will find a parametric form of the ellipse first.
Let a , b and c be the semi-major axis length, semi-minor axis length and semi focal distance, respectively. We see that 2 c = ∥ ∥ ∥ F 2 − F 1 ∥ ∥ ∥ = 1 0 , so c = 5 . We also have a = 2 1 5 , and b = a 2 − c 2 = 2 5 5 .
The next step is to find an orthonormal basis { e 1 ^ , e 2 ^ } , where e 1 ^ is a unit vector in the direction of the major axis and e 2 ^ points in the direction of the minor axis. We see that e 1 ^ = ∥ ∥ ∥ F 2 − F 1 ∥ ∥ ∥ F 2 − F 1 = 5 1 ( 4 , − 3 ) and e 2 ^ = 5 1 ( 3 , 4 ) .
Then, we are ready to write the parametric form of the ellipse: r ( t ) = C + e 1 ^ a cos ( t ) + e 2 ^ b sin ( t ) = ( 1 , 5 ) + 2 3 ( 4 , − 3 ) cos ( t ) + 2 5 ( 3 , 4 ) sin ( t ) , where 0 ≤ t ≤ 2 π .
In the lowest and highest points of the ellipse, for some value of t = t 0 , we have that the y -component of r ′ ( t 0 ) is zero. In this case r ′ ( t ) = 2 3 ( − 4 , 3 ) sin ( t ) + 2 5 ( 3 , 4 ) cos ( t ) , so we have to solve 2 9 sin ( t 0 ) + 2 5 cos ( t 0 ) = 0 , which gives tan ( t 0 ) = − 9 4 5 .
We want to find cos ( t 0 ) and sin ( t 0 ) , and we get two values for each of them: cos ( t 0 ) = ± 1 6 1 9 and sin ( t 0 ) = ∓ 1 6 1 4 5 .
Finally, we get two points: r ( t 0 ) = ( 1 , 5 ) ± 2 1 6 1 ( 4 8 , − 1 6 1 ) . The lowest one has the least value of the y -coordinate, and that is ( x 0 , y 0 ) = ( 1 + 1 6 1 2 4 , 5 − 2 1 6 1 ) ≈ ( 2 . 8 9 1 4 6 , − 1 . 3 4 4 2 8 ) , making the answer 1 5 4 7 .
The coordinates of the painting hook are H = ( x 0 , y 0 ) . Call the nail points P and Q . We know that the sum of the lengths of the hook to P and the hook to Q must be 1 5 . We also know that the tension in the rope is uniform, and that the sum of the horizontal forces must be zero. Therefore, the unit vector from H to P must have an equal and opposite x component relative to the the unit vector from H to Q . Mathematically, the solution criteria are:
∣ P − H ∣ + ∣ Q − H ∣ = 1 5 ∣ P − H ∣ P x − H x + ∣ Q − H ∣ Q x − H x = 0
Solving results in ( x 0 , y 0 ) ≈ ( 2 . 8 9 1 5 , − 1 . 3 4 4 3 )
Here is the code for a hill-climbing solution (since the question is from a programming contest):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
Problem Loading...
Note Loading...
Set Loading...
Let p be the length of the rope between ( 5 , 2 ) and the hook. Since the rope has a length of 1 5 , the length of the rope between ( − 3 , 8 ) and the hook will be 1 5 − p .
The locus of points for the hook are then ( x − 5 ) 2 + ( y − 2 ) 2 = p 2 and ( x + 3 ) 2 + ( y − 8 ) 2 = ( 1 5 − p ) 2 . Eliminating p gives the ellipse 6 4 4 x 2 − 3 2 0 8 x + 7 5 6 y 2 − 7 9 4 4 y + 3 8 4 x y − 6 6 6 1 = 0 .
Due to gravity, the hook will fall to the lowest point of this ellipse, which is a y -value with only one x -value. Solving the ellipse equation for x gives x = 3 2 2 8 0 2 − 9 6 y ± 7 5 5 ( − 4 y 2 + 4 0 y + 6 1 ) , which has one x -value when − 4 y 2 + 4 0 y + 6 1 = 0 , or when y = 5 ± 2 1 1 6 1 .
The lower point solves to ( x 0 , y 0 ) = ( 1 + 1 6 1 2 4 1 6 1 , 5 − 2 1 1 6 1 ) , which makes ⌊ 1 0 3 ( x 0 + y 0 ) ⌋ = 1 5 4 7 .