講者:Arashi
日期:2020/03/22
大綱
甚麼是演算法
應對燈泡不亮的簡單演算法流程圖
特色
分治法
特色
步驟
動態規劃法
特色
步驟
實作
費氏數列
分治法解法
分治法解答
def count(n):
if st[n] != "-1":
return st[n]
if n == 0:
return 0
if n == 1:
return 1
st[n] = count(n-1) + count(n-2)
return st[n]
st = ("-1 " * 10000).split(" ")
n = int(input())
while n != -1:
print(count(n))
n = int(input())
動態規劃法解法
動態規劃法解答
def count(n):
if n == 0:
return 0
if n == 1:
return 1
return count(n-1) + count(n-2)
n = int(input())
print(count(n))
參考資源
演算法 - 維基百科. Retrieved from https://zh.wikipedia.org/wiki/%E7%AE%97%E6%B3%95
動態規劃 - 維基百科.Retrieved from https://zh.wikipedia.org/wiki/%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92
分治法:維基百科.Retrieved from https://zh.wikipedia.org/wiki/%E5%88%86%E6%B2%BB%E6%B3%95
[Leetcode][分治法]相關題目匯總/分析/總結.Retrieved from https://blog.csdn.net/qqxx6661/article/details/81568563
Ch15 動態規劃.Retrieved from https://hackmd.io/@qR5cY2d3Ql2AdYtLfHFxVg/ByZgGkLpW?type=view
參考資源
Thanks for listening