当前位置:网站首页>1091: two or three things in childhood (multi instance test)
1091: two or three things in childhood (multi instance test)
2022-07-06 07:06:00 【Huaze flowers】
Title Description
Redraiment When I was a child, I liked to walk and jump , He likes to jump up and down the stairs best .
But when he was young, he could only go up one step at a time or jump up two steps at once .
Now there is N Steps , Please calculate Redraiment From 0 Step to N There are several ways to walk the steps .
Input
Input includes multiple sets of data .
Each set of data includes a row :N(1≤N≤40).
Enter to 0 end
Output
Each input includes an output .
by redraiment Arrive at n The number of different steps .
The sample input
1 3 0
Sample output
1 3
// Take one step , Jump two steps , from 0 Go to the N rank , Several walking methods
// Enter multiple groups N, With 0 end
// Output several ways
// Input :
//1
//3
//0
// Output :
//1
//3
#include <stdio.h>
int main()
{
int n,a[100],b,i;
a[0]=1;
a[1]=2;
while(scanf("%d",&n))
{
if(n==0)
break;
if(n==1)
printf("1\n");
else if(n==2)
printf("2\n");
else if(n>2)
{
for(i=2;i<=n;i++)
{
a[i]=a[i-1]+a[i-2];
}
printf("%d\n",a[n-1]);
}
}
return 0;
}
Running results :
Submit :
According to the title , You can find it by listing a few numbers , Fibonacci series can be used to calculate
Simply list a few examples of using Fibonacci sequence :
1. The bifurcation of trees
2. Number of petals
3. Rabbit breeding
4.1,2 Go up the steps
边栏推荐
- After working for 10 years, I changed to a programmer. Now I'm 35 + years old and I'm not anxious
- Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
- Hydra common commands
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models. common‘ from ‘/home/yolov5/models/comm
- Configure raspberry pie access network
- A method to measure the similarity of time series: from Euclidean distance to DTW and its variants
- Huawei equipment configuration ospf-bgp linkage
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Zhongqing reading news
- LeetCode Algorithm 2181. 合并零之间的节点
猜你喜欢
UWA Pipeline 2.2.1 版本更新说明
kubernetes集群搭建Zabbix监控平台
win10 64位装三菱PLC软件出现oleaut32.dll拒绝访问
How to reconstruct the class explosion caused by m*n strategies?
[brush questions] how can we correctly meet the interview?
What is the difference between int (1) and int (10)? Senior developers can't tell!
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
Leetcode 78: subset
指尖上的 NFT|在 G2 上评价 Ambire,有机会获得限量版收藏品
随机推荐
PCL实现选框裁剪点云
MVVM of WPF
Raspberry pie serial port login and SSH login methods
1189. Maximum number of "balloons"
Refer to how customer push e-commerce does content operation
Development of entity developer database application
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
Leetcode 78: subset
【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
指尖上的 NFT|在 G2 上评价 Ambire,有机会获得限量版收藏品
升级版手机检测微信工具小程序源码-支持多种流量主模式
Wechat official account infinite callback authorization system source code, launched in the whole network
漏了监控:Zabbix对Eureka instance状态监控
Call, apply, bind rewrite, easy to understand with comments
Arduino tutorial - Simon games
Windows Server 2016 standard installing Oracle
AI on the cloud makes earth science research easier
医疗软件检测机构怎么找,一航软件测评是专家
26岁从财务转行软件测试,4年沉淀我已经是25k的测开工程师...
librosa音频处理教程