当前位置:网站首页>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
边栏推荐
- Protected (members modified by protected are visible to this package and its subclasses)
- JDBC tool class encapsulation
- JSP syntax and JSTL tag
- Linear algebra Chapter 1 - determinant
- Fundamentals of digital image processing (Gonzalez) I
- 線性代數第一章-行列式
- Latex quick start
- Supply chain service terms
- Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
- Write your own redistemplate
猜你喜欢
Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)
Latex快速入门
Contrôle automatique (version Han min)
Pytorch学习记录(十三):循环神经网络((Recurrent Neural Network)
In depth understanding of the relationship between dncblevel and noise denoising in the paper
Pytoch learning record (x): data preprocessing + batch normalization (BN)
自動控制(韓敏版)
Pytorch learning record (XII): learning rate attenuation + regularization
Anaconda installed pyqt5 and pyqt5 tools without designer Exe problem solving
线性代数第三章-矩阵的初等变换与线性方程组
随机推荐
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
Graphic numpy array matrix
Pytorch learning record (7): skills in processing data and training models
Generate excel template (drop-down selection, multi-level linkage)
去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots
In depth source code analysis servlet first program
Algèbre linéaire chapitre 1 - déterminants
Multithreading and high concurrency (2) -- detailed explanation of synchronized usage
Common programming records - parser = argparse ArgumentParser()
20 excellent plug-ins recommended by idea
RedHat realizes keyword search in specific text types under the directory and keyword search under VIM mode
SQL injection
治療TensorFlow後遺症——簡單例子記錄torch.utils.data.dataset.Dataset重寫時的圖片維度問題
Class loading and classloader understanding
Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
Problems and solutions of database migration
Linear algebra Chapter 2 - matrices and their operations
PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比