当前位置:网站首页>剑指 Offer 10- II. 青蛙跳台阶问题
剑指 Offer 10- II. 青蛙跳台阶问题
2022-06-11 08:28:00 【zmm_mohua】
剑指 Offer 10- II. 青蛙跳台阶问题
题目

代码
#include <iostream>
#include <vector>
using namespace std;
int numWays(int n) {
if(n == 0 || n == 1){
return 1;
}
vector<int> dp(n);
dp[0] = 1;
dp[1] = 2;
for(int i = 2; i < n; i++){
dp[i] = dp[i-1] + dp[i-2];
dp[i] %= 1000000007;
}
return dp[n-1];
}
int main(){
int n, res;
cin>>n;
res = numWays(n);
cout<<res;
return 0;
}
边栏推荐
- bat 批处理单独环境打包
- B+ super tree helps you know the underlying structure of MySQL
- 这几个小工具也太好用了
- uniapp 插件开发
- Polymorphic interview questions
- torch. unbind()
- 【node】npm部分
- 经典图论,深度优先和广度优先,拓扑,Prim和Krukal,该来温习啦
- Introduction to knowledge atlas -- yedda annotation
- Web design and website planning assignment 13 making video playlists
猜你喜欢

【1】 Integrated learning: quickly understand Integrated Learning

Uniapp plug-in development

Interprocess communication

知识图谱入门之---yedda标注

(resolved) the tqdm progress bar in the Jupiter notebook does not update and display in one line, but scrolls down to output

torch. roll

【CVPR2022】QueryDet论文精读

Mongodb--- automatically delete expired data using TTL index

Node error report sorting

Is the result too different from the goal? With the help of target management, you can reach the target accurately!
随机推荐
Uniapp plug-in development
Record a murder case caused by ignoring the @suppresslint ("newapi") prompt
torch. Var (), sample variance, parent variance
用飞项进行目标管理,不做职场上的“无头苍蝇”
(completely solved) dataframe assignment settingwithcopywarning: a value is trying to be set on a copy of a slice
Go language: string connection, digital conversion string
Entity class conversion cannot be reassigned
What is concurrent search set? Are you still worried about it? In fact, it is a problem of connected graph, which is not so difficult to understand
Idea annotation settings
深度学习入门之pytorch安装
Typescript distributed condition type
Pypharm startup is stuck, loading project
Use Jackson's @jsonproperty annotation to add one more field to the property name. Solution to the problem
Use of Excel to XML tool of TestLink
Typescript declaration merge
ActiveMQ简单教程,适合初学者,学习笔记yyds
Shell Programming Notes
Empty difference between postgrepsql and Oracle
In place reversal of a LinkedList
Use special characters to splice strings "+“