eolymp
bolt
Try our new interface for solving problems
Problems

Fibonaccimal Base

Fibonaccimal Base

The well known Fibonacci sequence is obtained by starting with 0 and 1 and then adding the two last numbers to get the next one. For example the third number in the sequence is \textbf{1} (\textbf{1}=\textbf{1}+\textbf{0}), the forth is \textbf{2} (\textbf{2}=\textbf{1}+\textbf{1}), the fifth is \textbf{3} (\textbf{3}=\textbf{2}+\textbf{1}) and so on. \textbf{Figure 1} - The first numbers in the Fibonacci sequence The sequence appears on many things in our life, in nature, and has a great significance. Among other things, do you know that all positive integer numbers can be represented as a sum of numbers in the Fibonacci sequence? More than that, all positive integers can be represented as a sum of a set of Fibonacci numbers, that is, numbers from the sequence, without repetition. For example: \textbf{13} can be the sum of the sets \{\textbf{13}\}, \{\textbf{5},\textbf{8}\} or \{\textbf{2},\textbf{3},\textbf{8}\} and \textbf{17} is represented by \{\textbf{1},\textbf{3},\textbf{13}\} or \{\textbf{1},\textbf{3},\textbf{5},\textbf{8}\}. Since all numbers have this property (do you want to try to prove this for yourself?) this set could be a nice way to use as a "base" to represent the number. But, as we have seen, some numbers have more than one set whose sum is the number. How can we solve that? Simple! If we add the constraint that the sets cannot have two consecutive Fibonacci numbers, than we have a unique representation for each number! This restriction is because the sum of any two consecutive Fibonacci numbers is just the following Fibonacci number. Now that we know all this we can prepare a nice way to represent any positive integer. We will use a binary sequence (just zeros and ones) to do that. For example, \textbf{17} = \textbf{1} + \textbf{3} + \textbf{13} (remember that no two consecutive Fibonacci numbers can be used). Let's write a zero for each Fibonacci number that is not used and one for each one that is used, starting at the right. Then, \textbf{17} = \textbf{100101}. See figure \textbf{2} for a detailed explanation. In this representation we should not have zeros at the left, this is, we should only write starting with the first one. In order for you to understand better, note that in this scheme, not using two consecutive Fibonacci numbers means that the binary sequence will not have two consecutive ones. When we use this representation for a number we say that we are using the Fibonaccimal base, and we write it like \textbf{17} = \textbf{100101} (\textbf{fib}). \textbf{Figure 2} - Explaining the representation of \textbf{17} in Fibonaccimal base Given a set of numbers in decimal base, your task is to write them in the Fibonaccimal base. \InputFile The first line of input contains a single number N, representing the quantity of numbers that follow (\textbf{1} ≤ \textbf{N} ≤ \textbf{500}). Than follow exactly \textbf{N} lines, each one containing a single positive integer smaller than \textbf{100 000 000}. These numbers can come in any order. \OutputFile You should output a single line for each of the N integers in the input, with the format "\textbf{DEC_BASE = FIB_BASE (fib)}". \textbf{DEC_BASE} is the original number in decimal base and \textbf{FIB_BASE} is its representation in Fibonaccimal base. See the sample output for an example.
Time limit 1 second
Memory limit 64 MiB
Input example #1
10
1
2
3
4
5
6
7
8
9
10
Output example #1
1 = 1 (fib)
2 = 10 (fib)
3 = 100 (fib)
4 = 101 (fib)
5 = 1000 (fib)
6 = 1001 (fib)
7 = 1010 (fib)
8 = 10000 (fib)
9 = 10001 (fib)
10 = 10010 (fib)