当前位置:网站首页>5. Dynamic programming -- Fibonacci series
5. Dynamic programming -- Fibonacci series
2022-07-28 10:16:00 【[email protected]】
Title Description :f(0) = 0, f(1) = 1,f(n) = f(n - 1) + f(n - 2), among n> 1. The answer needs to be modelled
1e9+7(1000000007)
public int fib(int n) {
int a = 0, b = 1, sum;
for(int i = 0; i < n; i++){
sum = (a + b) % 1000000007;
a = b;
b = sum;
}
return a;
}
Dynamic programming algorithm is
- For a scale of n The problem of , Break it down into k A smaller sub problem ( Stage ), Solve the subproblems in order , The solution of the previous subproblem , It provides useful information for the solution of the latter subproblem . In solving any subproblem , The local optimal solution is obtained through decision-making , Solve each sub problem in turn . Finally, you can make a simple judgment , Get the solution of the original problem .

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280958224678.html
边栏推荐
- centos7下安装mysql,网上文章都不太准
- _HUGE and __IMP__HUGE in “math.h“
- Digital construction of pharmaceutical industry is on the verge
- uni-app进阶之创建组件/原生渲染
- 定了!就在7月30日!
- leetcode——旋转数组的最小数字
- Irregular area of OSPF, LSA and serial number
- Go json.Decoder Considered Harmful
- Prometheus operation and maintenance tool promtool (IV) TSDB function
- Summary of key points of bank entry examination
猜你喜欢

PHP生成二维码(学习)

Flink - checkpoint Failure reason: Not all required tasks are currently running

Performance test of API gateway APIs IX in Google cloud T2a and T2D

Choosing a supplier service system is the first step for large health industry enterprises to move towards digital transformation

office2013以上输入数学公式

ES (8.1) certification topic

Aqua Data Studio 18.5.0导出insert语句

What are the advantages of MRO purchasing website for industrial products? One article will help you understand

It's settled! On July 30!

【JS高级】js之函数、重载、匿名函数、作用域及作用域链_03
随机推荐
记录一次idea中的父子项目修改project与module名称,亲测!
What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
【云驻共创】华为云:MetaStudio数字内容生产线,让虚拟世界与现实世界无缝融合
Aqua Data Studio 18.5.0导出insert语句
PHP生成二维码(学习)
Summary of key points of bank entry examination
初识SuperMap iDesktop
定了!就在7月30日!
Uni app advanced life cycle
什么样的知识付费系统功能,更有利于平台与讲师发展?
管道、管程、管态的区别
12、双指针——合并两个有序链表
[cloud based co creation] Huawei cloud: metastudio digital content production line, which seamlessly integrates the virtual world with the real world
Thinking and summary of technical personnel | R & D Efficiency
jvm原理
不登高山,不知天之高也;不临深溪,不知地之厚也
Being on duty less than 8 hours a day and being dismissed? Tencent's former employees recovered 13million overtime pay, etc., and the court won a compensation of 90000 in the final judgment
Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?
软件设计师考前20问,注意啦!!
[openharmony] [rk2206] build openharmony compiler (2)