当前位置:网站首页>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
边栏推荐
- 数据仓库建设思维导图
- Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
- Simple use of MySQL database: add, delete, modify and query
- 中青看点阅读新闻
- Bio model realizes multi person chat
- leetcode704. Binary search (find an element, simple, different writing)
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
- Applied stochastic process 01: basic concepts of stochastic process
- Interface automation test framework: pytest+allure+excel
- 巴比特 | 元宇宙每日必读:中国互联网企业涌入元宇宙的群像:“只有各种求生欲,没有前瞻创新的雄心”...
猜你喜欢
Fast target recognition based on pytorch and fast RCNN
[daily question] 729 My schedule I
攻防世界 MISC中reverseMe简述
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
Oracle数据库11gr2使用tde透明数据加密报错ora28353,如果运行关闭wallet会报错ora28365,运行打开wallet就报错ora28353无法打开wallet
【每日一题】729. 我的日程安排表 I
树莓派串口登录与SSH登录方法
Map of mL: Based on the adult census income two classification prediction data set (whether the predicted annual income exceeds 50K), use the map value to realize the interpretable case of xgboost mod
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models. common‘ from ‘/home/yolov5/models/comm
What is the difference between int (1) and int (10)? Senior developers can't tell!
随机推荐
Misc of BUU (update from time to time)
Every API has its foundation when a building rises from the ground
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models. common‘ from ‘/home/yolov5/models/comm
26岁从财务转行软件测试,4年沉淀我已经是25k的测开工程师...
Latex文字加颜色的三种办法
leetcode1020. 飞地的数量(中等)
leetcode841. Keys and rooms (medium)
因高额网络费用,Arbitrum 奥德赛活动暂停,Nitro 发行迫在眉睫
hydra常用命令
What does UDP attack mean? UDP attack prevention measures
Bitcoinwin (BCW): the lending platform Celsius conceals losses of 35000 eth or insolvency
Idea console color log
这个高颜值的开源第三方网易云音乐播放器你值得拥有
Simple use of MySQL database: add, delete, modify and query
Bitcoinwin (BCW): 借贷平台Celsius隐瞒亏损3.5万枚ETH 或资不抵债
基于PyTorch和Fast RCNN快速实现目标识别
Establishment and operation of cloud platform open source project environment
Babbitt | metauniverse daily must read: the group image of Chinese Internet enterprises pouring into metauniverse: "there are only various survival desires, and there is no ambition for forward-lookin
At the age of 26, I changed my career from finance to software testing. After four years of precipitation, I have been a 25K Test Development Engineer
Entity Developer数据库应用程序的开发