当前位置:网站首页>5、动态规划---斐波那契数列
5、动态规划---斐波那契数列
2022-07-28 09:58:00 【[email protected]】
题目描述:f(0) = 0, f(1) = 1,f(n) = f(n - 1) + f(n - 2), 其中 n> 1。答案需要取模
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;
}
动态规划算法即
- 对于一个规模为n的问题,将其分解为k个规模较小的子问题(阶段),按顺序求解子问题,前一子问题的解,为后一子问题的求解提供了有用的信息。在求解任一子问题时,通过决策求得局部最优解,依次解决各子问题。最后可以通过简单的判断,得到原问题的解。

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zjj1910066023/article/details/124635400
边栏推荐
- SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
- Flink - checkpoint Failure reason: Not all required tasks are currently running
- OSPF expansion configuration, routing principles, anti ring and re release
- 【云驻共创】企业数字化转型,华为云咨询与你同行
- Voice chat app - how to standardize the development process?
- 不登高山,不知天之高也;不临深溪,不知地之厚也
- Prometheus 运维工具 Promtool (四)TSDB 功能
- 银行入职考试要点汇总
- API 网关 APISIX 在Google Cloud T2A 和 T2D 的性能测试
- 我用小程序容器让移动研发效率提升了5倍!
猜你喜欢

Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?

In retaliation for the dismissal of the company, I changed all code comments of the project!

建筑建材行业B2B电子商务网站方案:赋能建材企业转型升级,实现降本提效
![[ESP32][esp-idf] esp32s3快速搭建LVGLV7.9](/img/39/8efef047d0a9223b97819a54b5edf8.png)
[ESP32][esp-idf] esp32s3快速搭建LVGLV7.9

Redis面试题必知必会

Digital transformation scheme of real estate: all-round digital intelligence system operation, helping real estate enterprises improve the effectiveness of management and control

定了!就在7月30日!

记录一次idea中的父子项目修改project与module名称,亲测!
JWT 登录认证 + Token 自动续期方案,写得太好了!

Xiao Hei stands up again and looks at leetcode:653. Sum of two IV - enter BST
随机推荐
Installing MySQL for Linux operating system (centos7)
【JZOF】14剪绳子
安装gmp
ES (8.1) certification topic
二分、三分、01分数规划【第III弹】
The blind box of super primitive series will be launched soon, and platofarm will enable more rights and interests
Talk about the problem of preventing others from debugging websites through console based on JS implementation
Description of landingsite electronic label quppa firmware entering DFU status
Etcd(高可用KV数据库)
web之圣杯和双飞翼布局、float、clear、both
ELK实时日志分析平台
Openatom openharmony sub forum, see you today at 14:00! Wonderful release of memorabilia attached
[cloud co creation] enterprise digital transformation, Huawei cloud consulting is with you
工业品MRO采购网站有哪些优势?一文带你读懂
02.1.2.逻辑类型 bool
Massive data topn problem
Which strings will be resolved to null by fastjason?
CGAL编译错误
Redis design specification
[esp32][esp idf] ap+sta realizes wireless bridging and transferring WiFi signals