Skip to content

Commit deeb553

Browse files
authored
docs: add a description of the solution to lc problem: No.1414 (doocs#701)
* docs: add a description of the solution to lc problem: No.1414 No.1414.Find the Minimum Number of Fibonacci Numbers Whose Sum Is K * fix: fix pseudocode format
1 parent 0eef417 commit deeb553

File tree

1 file changed

+15
-0
lines changed
  • solution/1400-1499/1414.Find the Minimum Number of Fibonacci Numbers Whose Sum Is K

1 file changed

+15
-0
lines changed

solution/1400-1499/1414.Find the Minimum Number of Fibonacci Numbers Whose Sum Is K/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@
5353

5454
<!-- 这里可写通用的实现逻辑 -->
5555

56+
由于斐波那契数特点,数字重用在此题中是一个烟雾弹。举例推导:`k = 288`,数列(局部)`1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377`,可以由两个 144,或 `233 + 55` 组成;`k = 10`,可以由两个 5 或 `8 + 2` 组成。
57+
58+
由此可以使用贪心策略,逆向遍历斐波那契数列,进行暴力查找:
59+
60+
```txt
61+
FIND-MIN-FIBONACCI-NUMBERS(k)
62+
r = 0
63+
for n in f
64+
if k >= n
65+
k -= n
66+
r++
67+
if k === 0
68+
return res
69+
```
70+
5671
<!-- tabs:start -->
5772

5873
### **Python3**

0 commit comments

Comments
 (0)