当前位置:网站首页>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
边栏推荐
- 線性代數第二章-矩陣及其運算
- PyQy5学习(四):QAbstractButton+QRadioButton+QCheckBox
- Filebrowser realizes private network disk
- Denoising paper - [noise2void, cvpr19] noise2void learning denoising from single noise images
- PHP processing JSON_ Decode() parses JSON stringify
- 卡尔曼滤波与惯性组合导航
- Best practices for MySQL storage time
- PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比
- 如何利用对比学习做无监督——[CVPR22]Deraining&[ECCV20]Image Translation
- Pytorch学习记录(十一):数据增强、torchvision.transforms各函数讲解
猜你喜欢

Pytorch学习记录(十三):循环神经网络((Recurrent Neural Network)

Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)

On traversal of binary tree
![Comparative study paper - [Moco, cvpr2020] momentum contract for unsupervised visual representation learning](/img/21/4bc94fe29f416c936436c04fc16fa8.png)
Comparative study paper - [Moco, cvpr2020] momentum contract for unsupervised visual representation learning

Pyqy5 learning (2): qmainwindow + QWidget + qlabel

Pytorch learning record (III): structure of neural network + using sequential and module to define the model

线代第四章-向量组的线性相关

Linear algebra Chapter 2 - matrices and their operations

線性代數第一章-行列式

Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)
随机推荐
A sharp tool to improve work efficiency
Delete and truncate
Configure domestic image accelerator for yarn
Filebrowser realizes private network disk
SQL optimization best practices
图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi
Rsync for file server backup
卡尔曼滤波与惯性组合导航
Anaconda installed pyqt5 and pyqt5 tools without designer Exe problem solving
How to grow at work
Create binary tree
Generate excel template (drop-down selection, multi-level linkage)
Create enterprise mailbox account command
PyQy5学习(四):QAbstractButton+QRadioButton+QCheckBox
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
Code neat way to learn
去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots
MySQL basic madness theory
Development environment EAS login license modification
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention