eolymp
bolt
Try our new interface for solving problems
Problems

Decomposing Fibonacci Numbers

Decomposing Fibonacci Numbers

Some Fibonacci numbers are immune to zombie attack - as prime numbers they can't be decomposed. Fibonacci numbers are defined by the following recurrence: \includegraphics{https://static.e-olymp.com/content/54/54217ddf6fc583d7640d1f0982545c315014ce43.jpg} \includegraphics{https://static.e-olymp.com/content/71/71ed8be2ac94b3db320249481fde7c0e39117d5b.jpg} \includegraphics{https://static.e-olymp.com/content/64/64aaabc8585f507befd86e944c9f745318171ab2.jpg} You will be given an indefinite number of integer ranges of numbers that can be represented as \textbf{64}-bit signed integers. Your job is to report in increasing order the Fibonacci numbers that fall within that range, as well as their base-\textbf{2} logarithm and their prime decomposition - the prime numbers in increasing order which, when multiplied together, give the value of the Fibonacci number. If there is no Fibonacci number in the range, report that fact. \textit{\textbf{Reminder:}} \begin{itemize} \item the logarithm of zero is undefined, even though zero is the first Fibonacci number. Also note that, by definition, \textbf{0} and \textbf{1} have no prime factors, even though they are Fibonacci numbers. \item to calculate the base \textbf{c} logarithm, note that \textbf{ log_c(x) = log(x)/log(c)}, using on the right-hand side your favorite logarithm (common logarithm or natural logarithm). \end{itemize} \InputFile The input file contains an indeterminate number of lines consisting of two non-negative integers (\textbf{lo} and \textbf{hi}) separated by one space, given in hexadecimal format (as in \textbf{0x1a} meaning \textbf{26} in decimal). Each integer is guaranteed to fit within a \textbf{64}-bit signed integer. The program terminates when it either encounters an end-of-file condition or when \textbf{lo} > \textbf{hi}. \OutputFile For each range in the input file, print the range and the Fibonacci number information as shown in the sample output, with each range separated by a blank line. Note that the base-\textbf{2} logarithm (\textbf{lg}) is reported with six digits to the right of the decimal point, and that the prime factors are separated by single spaces.
Time limit 1 second
Memory limit 64 MiB
Input example #1
0x0 0x8
Output example #1
Range 0 to 8:
Fib(0) = 0, lg does not exist
No prime factors
Fib(1) = 1, lg is 0.000000
No prime factors
Fib(2) = 1, lg is 0.000000
No prime factors
Fib(3) = 2, lg is 1.000000
Prime factors: 2
Fib(4) = 3, lg is 1.584963
Prime factors: 3
Fib(5) = 5, lg is 2.321928
Prime factors: 5
Fib(6) = 8, lg is 3.000000
Prime factors: 2 2 2
Source ACM ICPC North America - Pacific Northwest 2010