Number of steps in Euclidean Algorithm

Problem #385

Tags: mathematics simple c-1

Who solved this?

No translations... yet

This problem was created by Mathias Kern aka gardengnome - many thanks!

In the Euclidean algorithm, two integers x and y with x>=y are replaced with y and x mod y until y becomes 0. For example:

Overall, the algorithm took three steps.

Your task is to find integer pairs for which the Euclidean algorithm runs exactly n steps.

Input: The first line contains the number t of test cases.
The second line contains t integer values – each is the count of target steps for the Euclidean algorithm.

Output: A single line of t space-separated integer pairs x and y with x >= y >=1 so that the Euclidean algorithm for the i-th pair takes exactly the i-th target number of steps.

Example:

input:
2
1 3

answer:
111 111 9 7
You need to login to get test data and submit solution.