eolymp
bolt
Try our new interface for solving problems
Problems

Overlapping Maps

Overlapping Maps

Fred and Sam are traveling together. Both have maps of the area. The maps cover exactly the same territory, and have exactly the same ratio of width to height, but Sam’s is at a smaller scale than Fred’s, so it’s a bit smaller. Fred puts his map on a table. Sam throws his map on top of it. The smaller map is offset and rotated, but it still fits entirely on top of the bigger map. Fred sticks a pin in the smaller map. The pin goes all the way through to the bigger map. Sam is amazed! He says "\textit{Wow! Do you realize that the position of that pin represents the same place on BOTH maps?}" Fred says "\textit{it’s really not so amazing. There has to be one such point!}" Given the dimensions of a large map, and the offset, scale and rotation of a smaller map that is entirely on top of the larger map, find the single point that represents the same place on both maps. \InputFile There will be several test cases in the input. Each test case will consist of a single line with six integers: \textbf{w h x y s r} The first two integers \textbf{w} and \textbf{h} (\textbf{0} < \textbf{w}, \textbf{h} ≤ \textbf{1000}) are the width and height of the larger map. The larger map will be on a plane, with the southwest corner at the origin, the northwest corner at \textbf{(0,h)}, the southeast corner at \textbf{(w,0)}, and the northeast corner at \textbf{(w,h)}. The next two integers, \textbf{x} and \textbf{y} (\textbf{0} ≤ \textbf{x} ≤ \textbf{w}, \textbf{0} ≤ \textbf{y} ≤ \textbf{h}), represent the \textbf{(x,y)} coordinate on the plane of the southwest corner of the smaller map. The integer \textbf{s} (\textbf{0} < \textbf{s} < \textbf{100}) represents the scale of smaller map as a percentage of the larger map (\textbf{s=50} means that the smaller map has half the width and half the height of the larger map). The integer \textbf{r} (\textbf{0} ≤ \textbf{r} < \textbf{360}) is the angle, in degrees, of counter-clockwise rotation of the smaller map around its southwest corner (\textbf{r=90} means that the southeast corner is rotated to be due north of the southwest corner). The smaller map is guaranteed to lie completely within the borders of the larger map. The input will end with a line with six \textbf{0}s. \OutputFile For each test case, output two real numbers, \textbf{x} and \textbf{y}, representing the \textbf{(x,y)} coordinate of the point where both maps represent the same place. Output the numbers to two decimal places of accuracy, with a single space between them. Do not output any extra spaces. Do not put blank lines between answers for different cases.
Time limit 1 second
Memory limit 64 MiB
Source The University of Chicago Invitational Programming Contest 2013, March 29-31, 2013