Maniacal Midsummer Marathon 2014 by AL, TL, JJ
It is not widely known, but outside of playing Hearthstone and watching NGNL, Ben is actually a quantum mechanics expert. He is very interested in string theory, but he heard that in order for string theory to be mathematically consistent, the concept of more than just spatial dimensions must be introduced. While fooling around on Wikipedia all day (his primary research routine), he discovered that "flat space string theories are -dimensional in the bosonic case while superstring and M-theories turn out to involve or dimensions for flat solutions." Whatever that meant, Ben read it and was in hysterics.
"HA", he exclaimed. "Physicists are such noobs these days. dimensions? dimensions? How about dimensions. Ain't nothing I can't handle."
While Ben was probably referring to his ability to solve physics problems in dimensions, the universe had heard this statement and was not impressed. That night while Ben was still in his dreams, the fabric of space-time in his realm had transferred him to -D Land (where the number of dimensions , as Ben boasted he could handle). After waking up, Ben finds himself on a rocket ship hurtling through space.
The first thing he noticed was that everything around him is extremely … weird. He was able to glide around the ship in so many miraculous directions that he never thought existed. Just as his puny -D brain was busy being overwhelmed by the new change of universes, a series of loud beeps from the front of the ship caught his attention. Approaching the dashboard, he saw the flashing message: ENERGY LEVEL: CRITICALLY LOW. Ben looked out the window and noticed nothing but pitch darkness. After getting the Newton's first law question wrong on his physics test, he learned that a constantly moving object will not stop unless acted on by any external, unbalanced forces. That means Ben's ship is bound to go on forever until it gets absorbed by a star, torn apart by a black hole, or demolished by a planet, space junk, or whatever obstacles occupy the peculiar universe. His ship's energy will soon run out, so there is no chance of him turning it around when these things happen. He'll just have to accept his sad fate.
"How unfortunate", he thought to himself, "that such a brilliant young physicist like me shall perish in the abyss of this unfamiliar world." He let out a sigh as he stared out of the spaceship window into the darkness of outer space.
But wait! Just as he was about to give up hope, he noticed a faint glow in the distance. Alas - it's a star! But … why is it moving so quickly!?! Ah yes, that's when Ben remembered from one of his Wikipedia readings that this is probably a hypervelocity star, that is, a star moving so quickly that its velocity exceeds the escape velocity of its galaxy.
"What massive amounts of energy must be involved with such a majestic cosmic entity", Ben thought to himself, "there is hope now!"
After some digging through manuals, Ben discovered that, sure enough, his rocket ship had integrated energy collection capabilities. The ship is able to capture the radiant and thermal energy of any nearby object — the closer the object, the more energy will be transferred over to the ship! The encounter with this star might be his only chance to repower ship, so Ben better make the absolute most out of the energy transfer or risk dying in this realm of a bajillion dimensions.
In -D Land, every point in space can be represented using a coordinate of numbers . We shall let two such -dimensional points and respectively represent the locations of Ben's ship and the HV star at . Ben's velocity is represented by the vector . This means that during every unit of time, the value describing Ben's position in the dimension will increase by . Similarly, the velocity of the star can be represented by the vector .
Knowing these pieces of information, Ben would like to find out just how close he is ever going to get to the star, and at what time he will get the closest. Please help him make the most of this energy transfer!
Input Specification
The line contains a single integer ,
the number of dimensions.
The line contains integers, the coordinates of , representing
Ben's initial position at .
The line contains integers, the coordinates of , representing
the HV star's initial position at .
The line contains integers, the velocity vector , where
the integer represents the distance moved in the
coordinate of point during each unit of time after .
The line contains integers, the velocity vector , where
the integer represents the distance moved in the
coordinate of point during each unit of time after .
Each number in the input will be between and .
Output Specification
Output a single nonnegative real number - the time at which the
Euclidean distance between Ben and the star will be minimized.
If the time is not unique, output the smallest value of such
that Ben and the star's Euclidean distance will be minimized.
Your output will be considered correct if it is accurate to
( digits after the decimal).
Sample Input 1
2
0 0
5 0
1 1
0 2
Sample Output 1
2.5
Explanation for Sample 1
In this example, Ben happens to have been transferred to -D land. Ben starts out at and the star starts out at . Every unit of time, Ben moves unit in the positive -direction and unit in the positive -direction. Every unit of time, the star moves by in the positive -direction. Ben performs the energy transfer at , when the ship will be at and the star will be at . This is the closest they'll ever be, with a distance of . The scenario is depicted in the figure below.
Sample Input 2
4
0 0 0 0
0 0 0 1
0 0 0 -1
0 0 0 -1
Sample Output 2
0
Explanation for Sample 2
In this example, Ben has been transferred to -D land. He is located at and the star is located at . Every second, Ben and the star will both move in the dimension. This means that Ben and the star will forever be unit of distance apart, so he might as well make the energy transfer immediately, at .
Comments