# P3539 [POI2012]ROZ-Fibonacci Representation

• 183通过
• 482提交
• 题目提供者 洛谷
• 评测方式 云端评测
• 标签 贪心 POI 2012
• 难度 提高+/省选-
• 时空限制 1000ms / 128MB
• 提示：收藏到任务计划后，可在首页查看。

## 题目描述

The Fibonacci sequence is a sequence of integers, called Fibonacci numbers, defined as follows:

$Fib_{0}=0,Fib_{1}=1,Fib_{n}=Fib_{n-2}+Fib_{n-1}\ for\ n>1$

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:

$10=5+5$

$19=21-2$

$17=13+5-1$

$1070=987+89-5-1$

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.

给一个数，问最少可以用几个斐波那契数加加减减凑出来

例如 10=5+5 19=21-2

17=13+5-1

1070=987+89-5-1

## 输入输出格式

输入格式：

In the first line of the standard input a single positive integer $p$ is given ($1\le p\le 10$) that denotes the number of queries. The following $p$ lines hold a single positive integer $k$ each ($1\le k\le 1\times 10^{17}$).

多组数据

输出格式：

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.

## 输入输出样例

输入样例#1： 复制
1
1070
输出样例#1： 复制
4

## 说明

给一个数，问最少可以用几个斐波那契数加加减减凑出来

提示
标程仅供做题后或实在无思路时参考。
请自觉、自律地使用该功能并请对自己的学习负责。
如果发现恶意抄袭标程，将按照I类违反进行处理。