当前位置:网站首页>Maomao goes to work (recursive)
Maomao goes to work (recursive)
2022-07-19 06:54:00 【winkiii】
describe
Maomao finally succeeded in applying for the job after countless hardships , Work in a software company , But because the house he rented is far away , And his electric car is older , You need to recharge every time you ride a section of the road , Fortunately, the charging speed is relatively fast , He just had time to rush to work .
Between the company and the rented house M-2 A charging station , His electric car can ride 1 Station or 2 Distance of the station , Set the first 1 The station is a rented house , The first M The station is a company , And the battery was full at the beginning , How many ways can he go to the company ?
Input
Multiple sets of test data , Please use while(…) Read in the data , until EOF.
Each set of data contains an integer M(2<=M<=40), Indicates the total number of stations .
Output
For each set of data , Please output the number of different charging methods .
sample input 1
2
3
sample output 1
1
2
#include<stdio.h>
int charge(int n){
if(n==2) return 1;
else if(n==3) return 2;
else if(n>3){
return charge(n-1)+charge(n-2);
}
}
int main(){
int m;
while(scanf("%d",&m)!=EOF){
printf("%d\n",charge(m));
}
}
边栏推荐
- Wu Enda machine learning chapter 1-2
- BigDecimal中divide方法
- Openssl--- stack
- Causes and solutions of over fitting
- 毛毛上班(递推)
- 2019cs brand sdnand and EMMC selection comparison important analysis
- F5LTM(一)逻辑关系图
- Loadng class `com. mysql. jdbc. Driver‘. This is deprecated. The new driver class is `com. mysql. cj. jdb
- wireshark抓包:报文信息
- FreeBSD 12 国内源提速 pkg 和 ports 做个笔记
猜你喜欢

What is tsd/qsd? What is CS Genesis SD NAND?

Wireshark packet capture: message information

Relevant knowledge points of Gugao motion control card

Common user password encryption methods and cracking methods

Comparison between CS brand SD NAND and SPI NAND

Wu Enda machine learning chapter 14-15

Application case of CS brand SD NAND in air quality inspection industry
![[CS Genesis] comparative analysis of advantages and disadvantages of SD NAND and raw NAND](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[CS Genesis] comparative analysis of advantages and disadvantages of SD NAND and raw NAND

Wu Enda machine learning chapter 8-9

Tcp/ip four layer model and related configurations of F5
随机推荐
postgresql 数据库如何设置主键自增长
Wu Enda machine learning chapter 6-7
What is tsd/qsd? What is CS Genesis SD NAND?
汉诺塔2(函数)
Galaxy Kirin server system building local and LAN Yum source
手动字符串比较(指针题)
opensuse 安装网易云音乐(tumbleweed)(leap)
️️固高运动控制卡的相关知识点
上课啦要点名啊
渣渣学习之路(2)纯小白向:Win Server 2003服务器搭建
STM32串口通信相关学习
Tcp/ip protocol learning
基于SPI/IIC接口的OLED数据显示
各大云服务厂商 轻量应用服务器 性能评测对比,阿里云、腾讯云、华为云、Ucloud
文本三剑客之sed命令--文本替换;grep命令---文本过滤
小迪网络安全-笔记(4)
小迪网络安全-笔记(2)
小迪网络安全笔记 信息收集-CDN绕过技术(7)
Total price contract, cost compensation contract, labor contract
部署zabbix-agaent2与验证