|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|3 초||128 MB||5||4||4||80.000%|
The Fibonacci sequence is a sequence of integers, called Fibonacci numbers, defined as follows:
Its initial elements are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...
Byteasar investigates representations of numbers as sums or differences of Fibonacci numbers. Currently he is wondering what is the minimum representation, i.e., one with the minimum number of (not necessarily different) Fibonacci numbers, for a given positive integer k. For example, the numbers 10, 19, 17, and 1070 can be minimally represented using, respectively, 2, 2, 3, and 4 Fibonacci numbers as follows:
Help Byteasar! Write a program that, for a given positive integer k determines the minimum number of Fibonacci numbers required to represent k as their sum or difference.
In the first line of the standard input a single positive integer p is given (1 ≤ p ≤ 10) that denotes the number of queries. The following p lines hold a single positive integer k each (1 ≤ k ≤ 4⋅1017).
For each query your program should print on the standard output the minimum number of Fibonacci numbers needed to represent the number k as their sum or difference.