Benelux Algorithm Programming Contest 2014 Final I: Interesting Integers

I. Interesting Integers:

Undoubtedly you know of the Fibonacci numbers. Starting with F_1 = 1F1=1 and F_2 = 1F2=1,every next number is the sum of the two previous ones. This results in the sequence 1, 1, 2, 3, 5, 8, 13, \cdot\cdot\cdot1,1,2,3,5,8,13, .

Now let us consider more generally sequences that obey the same recursion relation

Gi =G_{i-1} +G_{i-2}Gi=Gi1+Gi2 for i>2i>2

but start with two numbers G_1 \le G_2G1G2 of our own choice. We shall call these Gabonacci sequences. For example, if one uses G_1 = 1G1=1and G_2 = 3G2=3, one gets what are known as the Lucas numbers: 1,3,4,7,11,18,29,\cdot\cdot\cdot1,3,4,7,11,18,29, . These numbers are – apart from 11 and 33 – different from the Fibonacci numbers.

By choosing the first two numbers appropriately, you can get any number you like to appear in the Gabonacci sequence. For example, the number n appears in the sequence that starts with 11 and n - 1n1, but that is a bit lame. It would be more fun to start with numbers that are as small as possible, would you not agree?

Input Format

On the first line one positive number: the number of test cases, at most 100100. After that per test case:

  • one line with a single integer nn (2 \le n \le 10^9)(2n109): the number to appear in the sequence.

Output Format

Per test case:

  • one line with two integers aa and bb (0 < a \le b)(0<ab),such that,for G_1 = aG1=a and G_2 = b, G_k = nG2=b,Gk=n for some kk. These numbers should be the smallest possible, i.e., there should be no numbers a{'}a and b{'}bwith the same property, for which b{'} < bb<b, or for which b{'} = bb=b and a{'} < aa<a.

样例输入

5
89
123
1000
1573655
842831057

样例输出

1 1
1 3
2 10
985 1971
2 7

猜你喜欢

转载自blog.csdn.net/qq_36561697/article/details/80999067
今日推荐