当前位置:网站首页>Fibonacci number of dynamic programming
Fibonacci number of dynamic programming
2022-07-07 23:29:00 【Little brother who loves Python】
Dynamic programming
Fibonacci number
/* Fibonacci sequence */
public class Fit {
public static int fit(int n){
if(n<2){
return n;
}
int[] dp = new int[n+1];
// Initialization of boundary value
dp[1] = 1;
for (int i = 2; i <= n ;i++){
// State transition equation
dp[i] = dp[i-1] + dp[i-2];
}
return dp[n];
}
public static void main(String[] args) {
int num = 0;
Scanner scanner = new Scanner(System.in);
if (scanner.hasNextInt()){
num = scanner.nextInt();
fit(num);
System.out.println(fit(num));
}else{
System.out.println(" The input is not a natural number !");
}
}
}```
边栏推荐
- 深入理解Mysql锁与事务隔离级别
- FreeLink开源呼叫中心设计思想
- Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the "largest possible number."
- Unity3d learning notes 4 - create mesh advanced interface
- Illegal behavior analysis 1
- Install Fedora under RedHat
- sql 数据库执行问题
- Matlab SEIR infectious disease model prediction
- JS get the key and value of the object
- Cloud native data warehouse analyticdb MySQL user manual
猜你喜欢

MySQL Index Optimization Practice II

UE4_ Use of ue5 blueprint command node (turn on / off screen response log publish full screen display)

移动端异构运算技术 - GPU OpenCL 编程(基础篇)
![MATLAB signal processing [Q & A essays · 2]](/img/be/0baa92767c3abbda9b0bff47cb3a75.png)
MATLAB signal processing [Q & A essays · 2]

Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night

2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?

Lm12 rolling heikin Ashi double K-line filter

Mysql索引优化实战一

PCB wiring rules of PCI Express interface

PCI-Express接口的PCB布线规则
随机推荐
UE4_ Ue5 combined with Logitech handle (F710) use record
Unity3d learning notes 4 - create mesh advanced interface
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
B_QuRT_User_Guide(38)
windows设置redis开启自动启动
MATLAB signal processing [Q & A essays · 2]
LDO voltage stabilizing chip - internal block diagram and selection parameters
Mysql索引优化实战二
First week of July
谷歌浏览器怎么登录及开启同步功能
Matlab SEIR infectious disease model prediction
系统架构设计师备考经验分享:论文出题方向
List. How to achieve ascending and descending sort() 2020.8.6
Bea-3xxxxx error code
PCI-Express接口的PCB布线规则
生鲜行业数字化采购管理系统:助力生鲜企业解决采购难题,全程线上化采购执行
Tree background data storage (using webmethod) [easy to understand]
SQL database execution problems
欢聚时代一面
做自媒体视频剪辑怎么赚钱呢?