当前位置:网站首页>12. Monkeys climb mountains
12. Monkeys climb mountains
2022-04-23 06:08:00 【linsa_ pursuer】
One day, a monkey wanted to climb from the foot of the mountain to the top of the mountain , On the way, there is a N A staircase of steps , But the monkey has a habit : You can only jump at a time 1 Step or jump 3 Step , How many different ways do monkeys jump through this ladder ?
Input
Enter only one integer N(0<N<=50) How many steps does this ladder have
Output
How many jump modes are output ( Number of solutions )
package com;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println(jump(s.nextInt()));
}
public static int jump(int num){
if(num<3){
return 1;
}
return jump(num-1)+jump(num-3);
}
}
Such as :
Input :
3
50
Output :
2
版权声明
本文为[linsa_ pursuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220533259581.html
边栏推荐
- Fundamentals of in-depth learning -- a simple understanding of meta learning (from Li Hongyi's course notes)
- 图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi
- Optional best practices
- Dva中在effects中获取state的值
- CONDA virtual environment management (create, delete, clone, rename, export and import)
- Pytorch Learning record (XIII): Recurrent Neural Network
- 常用编程记录——parser = argparse.ArgumentParser()
- 给yarn配置国内镜像加速器
- container
- Gaussian processes of sklearn
猜你喜欢
Comparative study paper - [Moco, cvpr2020] momentum contract for unsupervised visual representation learning
Framework analysis 1 Introduction to system architecture
The user name and password of users in the domain accessing the samba server outside the domain are wrong
Generate excel template (drop-down selection, multi-level linkage)
You cannot access this shared folder because your organization's security policy prevents unauthenticated guests from accessing it
Contrôle automatique (version Han min)
PyQy5学习(二):QMainWindow+QWidget+QLabel
Latex快速入门
Automatic control (Han min version)
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images
随机推荐
Automatic control (Han min version)
Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
Fact final variable and final variable
Pytorch学习记录(十三):循环神经网络((Recurrent Neural Network)
线代第四章-向量组的线性相关
A sharp tool to improve work efficiency
去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots
深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索
umi官网yarn create @umijs/umi-app 报错:文件名、目录名或卷标语法不正确
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
2. Average length of words
数字图像处理基础(冈萨雷斯)二:灰度变换与空间滤波
Pytorch learning record (7): skills in processing data and training models
Implementation of displaying database pictures to browser tables based on thymeleaf
Fundamentals of SQL: first knowledge of database and SQL - installation and basic introduction - Alibaba cloud Tianchi
Remedy after postfix becomes a spam transit station
Numpy common function table sorting of data processing
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
MySQL basic madness theory
The official website of UMI yarn create @ umijs / UMI app reports an error: the syntax of file name, directory name or volume label is incorrect