eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Treasure Map

Treasure Map

\includegraphics{https://static.e-olymp.com/content/54/544b29fb7300269a620e822baf7a3af0d80c7e54.jpg} "\textit{Take }\textbf{147}\textit{ steps due north, turn }\textbf{63}\textit{ degrees clockwise, take }\textbf{82}\textit{ steps, ...}". Most people don't realize how important accuracy is when following the directions on a pirate's treasure map. If you're even a tiny bit off at the start, you'll end up far away from the correct location at the end. Pirates therefore use very exact definitions. One step, for instance, has been defined by the \textbf{1670} Pirate Convention to be exactly two times the size of the wooden leg of Long John Silver, or \textbf{1.183} m in metricunits. Captain Borbassa was thus not at all worried when he set sail to the treasure island, having a rope with knots in it, exactly one step apart, for accurately measuring distances. Of course he also brought his good old geotriangle, once given to him by his father when he was six years old. \includegraphics{https://static.e-olymp.com/content/8a/8a60c13c4e76b6442dfcb69975546e105cc24571.jpg} \includegraphics{https://static.e-olymp.com/content/8a/8a60c13c4e76b6442dfcb69975546e105cc24571.jpg} However, on closer inspection of the map, he got an unpleasant surprise. The map was made by the famous captain Jack Magpie, who was notorious for including little gems into his directions.In this case, there were distances listed such as steps. How do you measure that accurately? Fortunately, his first mate Pythagor came to the rescue. After puzzling for a few hours, he came up with the following solution: let pirate \textbf{A} go \textbf{4} steps into the perpendicular direction, and hold one end of the measuring rope there. Then pirate \textbf{B} goes into the desired direction while letting the rope slide through his fingers, until he is exactly \textbf{7} steps away from pirate \textbf{A}. Pythagor worked out a formula that states that pirate \textbf{B} has then traveled exactly steps. Captain Borbassa was impressed, but he revealed that there were more such distances on the map. Paranoid as he is, he refuses to let Pythagor see the map, or even tell him what other distances there are on it. They are all square roots of integers, that's all he gets to know. Only on the island itself will the captain reveal the numbers, and then he expects Pyhtagor to quickly work out the smallest two integer numbers of steps that can combine to create the desired distance, using the method described above. Pythagor knows this is not easy, so he has asked your help. Can you help him by writing a program that can determine these two integers quickly? By the way, he did ask the captain how large the numbers inside the square root could get, and the captain replied "one billion". He was probably exaggerating, but you'd better make sure the program works. If you can successfully help the pirates, you'll get a share of the treasure. It might be gold, it might be silver, or it might even be... a treasure map! \InputFile The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format: \begin{itemize} \item One line with one integer \textbf{N}, satisfying \textbf{1} ≤ \textbf{N} ≤ \textbf{10^9}. \end{itemize} \OutputFile \includegraphics{https://static.e-olymp.com/content/bf/bfcfdf2c08e60429679fd7d5f5f808e6e903b283.jpg} For every test case in the input, the output should contain two nonnegative integers, separated by a space, on a single line: the distance pirate \textbf{A} needs to head in the perpendicular direction, and the final distance between pirate \textbf{A} and \textbf{B}, such that pirate \textbf{B} has traveled steps. If there are multiple solutions, give the one with the smallest numbers. If there are no solutions, the output should be "\textbf{IMPOSSIBLE}" (without the quotation marks) on a single line.
Лимит времени 1 секунда
Лимит использования памяти 32 MiB
Входные данные #1
4
33
16
50
101
Выходные данные #1
4 7
0 4
IMPOSSIBLE
50 51
Источник ICPC BAPC 2011 Finals